Urgent: regarding sub select statement
I making a report in which i have to display the STOCK and i want to do the sum in a select statement of the value coming from the field AFRU-GMNGA so that i can do calculation of the value of 1st field to be subtracted from the last value of the same field .
can anybody provide me example of it as i am currently using dis select statement:-
SELECT AMATNR ALGORT BGMNGA BVORNR C~MEINS FROM AFPO AS A
INNER JOIN AFRU AS B ON AAUFNR = BAUFNR
INNER JOIN MARA AS C ON AMATNR = CMATNR
INTO TABLE ITAB
WHERE MTART IN MAT_TYPE AND A~MATNR IN P_MATNR .
plzz help me out as it is really urgent to me.
Hi,
Go thr the below select query.
select tvkwzwerks a350kschl a350vkorg konpkbetr
from tvkwz inner join a350 on tvkwzvkorg = a350vkorg inner join konp
on a350knumh = konpknumh into table itab where tvkwz~werks = '1003'
and a350~kschl = 'ZCPA'.
Regards,
vijay
Similar Messages
-
Regarding max select statement.
hi ,
i m using max in select statement but its nt showing the o/p,cud u plz help me..thnx in advce.here i m giving the code....
tables:s032.
select-options:s_matnr for s032-matnr.
data:begin of itab occurs 0,
matnr like s032-matnr,
letztzug like s032-letztzug,
end of itab.
select matnr
MAX( letztzug )
into corresponding
fields of
table itab from s032 where matnr in s_matnr
group by matnr
order by
matnr
loop at itab.
write:/ itab-matnr,itab-letztzug.
endloop.select matnr
MAX( letztzug )
into
table itab from s032 where matnr in s_matnr
group by matnr
order by
matnr
dont use corresponding fields of clause it is not matching the field name with max function.
regards
shiba dutta -
Regarding this select statement
hi,
i am not getting value i write like this select statement
plz check error in this code.
TABLES: VBAK,
vbrk.
TYPES: BEGIN OF TYP_VBAK,
VBELN TYPE VBELN_VA,
VBTYP TYPE VBTYP,
VGBEL TYPE VGBEL,
END OF TYP_VBAK,
BEGIN OF TYP_VBRK,
VBELN TYPE VBELN,
WAERK TYPE WAERK,
VKORG TYPE VKORG,
KNUMV TYPE KNUMV ,
FKDAT TYPE FKDAT,
LAND1 TYPE LLAND,
NETWR TYPE NETWR,
KUNRG TYPE KUNRG,
EXNUM TYPE EXNUM,
MWSBK TYPE MWSBP,
END OF TYP_VBRK.
DATA: GT_VBAK TYPE TABLE OF TYP_VBAK,
IT_VBRK TYPE standard TABLE OF TYP_VBRK WITH HEADER LINE.
LS_VBRK TYPE TYP_VBRK,
SELECT VBELN
WAERK
VKORG
KNUMV
FKDAT
LAND1
NETWR
KUNRG
EXNUM
FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
WHERE VBELN = '0090060045'.Check from SE16 whether vbeln = 0090060045 is present in VBRK or not.
Regards,
Joy. -
hi,
i got a select statement in my program as shown below
select * from ce4e001 where bukrs eq s_bukrs-low.
check s_kndnr.
check s_prctr.
move-corresponding ce4e001 to v_ce4e001.
append v_ce4e001.
endselect.
now i want to rewrite this select statement with using into table like
select * from ce4e001 into table v_ce4e001 where bukrs eq s_bukrs-low.
but my problem is
in the initial select statement they have used two check statements before appending
now how can i incorporate those two check statements in my new select statement
thanks
ramHi Ram,
Not sure why the check keywords where embedded within the select statments...it will have no impact if the selection variable where outside.
You could rewrite your new code as:
check s_kndnr.
check s_prctr.
select * from ce4e001 into table v_ce4e001 where bukrs eq s_bukrs-low.
Assign points if it works.
Thanks
-Saif -
Urgent: regarding sub total button in alv report
hi,
i had made dis report and it is is fine till now,but now i want add the sub total field in it ,by making double click on the field sub-total should be displayed in it.
here is d code as i had tried the sub - total but when i execute it is giving some diferrent result.
*& Report ZTET2
REPORT ZTET2.
TABLES: ISEG,MARA.
TYPE-POOLS : SLIS.
DATA : DATE1(15) TYPE C,
DATE2(15) TYPE C,
TITLE(65) TYPE C,
DT(25) TYPE C.
DATA : ITEVENT TYPE SLIS_T_EVENT.
DATA: lv_sort TYPE slis_sortinfo_alv,
t_sort type slis_t_sortinfo_alv.
DATA : repid LIKE sy-repid.
INTERNAL TABLE FOR INVENTORY STOCK *****************
DATA: BEGIN OF ITS1 OCCURS 0,
MATNR LIKE ISEG-MATNR,
ITEMID(6) TYPE C,
MEINS LIKE ISEG-MEINS,
MENGE LIKE ISEG-MENGE,
WRTZL LIKE ISEG-WRTZL,
BUCHM LIKE ISEG-BUCHM,
WRTBM LIKE ISEG-WRTBM,
WERKS LIKE ISEG-WERKS,
BUDAT LIKE ISEG-BUDAT,
ZLDAT LIKE ISEG-ZLDAT,
MTART LIKE MARA-MTART,
ITEMDESC LIKE MAKT-MAKTX,
DIFFQTY LIKE ISEG-BUCHM,
DIFFVALUE LIKE ISEG-WRTBM,
GRUND LIKE ISEG-GRUND,
GRTXT LIKE T157E-GRTXT,
BWART LIKE T157E-BWART,
REAS TYPE C LENGTH 15,
END OF ITS1.
data: t_heading type slis_t_listheader.
SELECTION-SCREEN BEGIN OF BLOCK PAR1 WITH FRAME TITLE TEXT-001.
*SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
*********PARAMETERS*********
PARAMETERS : PLANT LIKE ISEG-WERKS OBLIGATORY.
*********SELECTION SCREEN OPTIONS*********
SELECT-OPTIONS : R_DATE FOR ISEG-BUDAT OBLIGATORY NO-EXTENSION,
M_TYPE FOR MARA-MTART,
IT_M FOR MARA-MATNR.
*********DEFINING VARIABLES*********
SELECTION-SCREEN END OF BLOCK par1.
CONCATENATE R_DATE-LOW6(2) '.' R_DATE-LOW4(2) '.' R_DATE-LOW+0(4) INTO DATE1.
CONCATENATE R_DATE-HIGH6(2) '.' R_DATE-HIGH4(2) '.' R_DATE-HIGH+0(4) INTO DATE2.
TOP-OF-PAGE.
PERFORM PG_HEADER.
START-OF-SELECTION.
SELECT AMATNR AMEINS AMENGE AWRTZL ABUCHM AWRTBM AWERKS ABUDAT AZLDAT BMTART AGRUND CBWART
FROM ISEG AS A INNER JOIN MARA AS B ON BMATNR = AMATNR
INNER JOIN MSEG AS C ON AMBLNR = CMBLNR
INTO CORRESPONDING FIELDS OF TABLE ITS1 WHERE BMATNR = AMATNR AND BMEINS = AMEINS AND AWERKS = PLANT AND ABUDAT IN R_DATE AND BMTART IN M_TYPE AND BMATNR IN IT_M.
LOOP AT ITS1.
ITS1-ITEMID = ITS1-MATNR+12(6).
ITS1-DIFFQTY = ITS1-MENGE - ITS1-BUCHM.
ITS1-DIFFVALUE = ITS1-WRTZL - ITS1-WRTBM.
SELECT SINGLE MAKTX FROM MAKT INTO ITS1-ITEMDESC WHERE MATNR = ITS1-MATNR.
SELECT SINGLE GRTXT INTO ITS1-GRTXT FROM T157E WHERE GRUND = ITS1-GRUND AND SPRAS = 'E' AND BWART = ITS1-BWART.
MODIFY ITS1.
ENDLOOP.
PERFORM PRN_SMSTOCK_ALV.
WRITING DATA FROM D TABLES**********
FORM PG_HEADER.
WRITE : 'PHYSICAL INVENTORY AUDIT REPORT PLANT : ', PLANT.
ENDFORM.
*& Form PRN_SMSTOCK_ALV
text
--> p1 text
<-- p2 text
form PRN_SMSTOCK_ALV .
data: w_title type lvc_title,
w_repid type syrepid,
w_comm type slis_formname,
w_status type slis_formname,
x_layout type slis_layout_alv,
t_event type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv,
t_subtot TYPE slis_t_sortinfo_alv,
subtot LIKE LINE OF t_subtot.
refresh t_fieldcat.
refresh t_event.
refresh t_sort.
clear x_layout.
clear w_title.
perform set_fieldcat2 using:
1 'MTART' 'MTART' 'MARA' '15' space 'MATERIAL TYPE' space space space space space space space space SPACE t_fieldcat 'L' 'L',
2 'ITEMID' 'ITEMID' 'MARA' '7' space 'ITEM ID' space space space space space space space space SPACE t_fieldcat 'R' 'C',
3 'ITEMDESC' 'MAKTX' 'MAKT' '25' space 'MATERIAL DESCRIPTION' space space space space space space space space SPACE t_fieldcat 'L' 'C',
4 'MEINS' 'MEINS' 'MARA' '5' space 'UOM' space space space space space space space space SPACE t_fieldcat 'C' 'C',
5 'MENGE' 'MENGE' 'ISEG' '13' space 'ORG.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
6 'WRTZL' 'WRTZL' 'ISEG' '13' space 'ORG.INV.VALUE' space space space space space space space space SPACE t_fieldcat 'R' 'C',
7 'BUCHM' 'BUCHM' 'ISEG' '13' space 'PHY.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
8 'WRTBM' 'WRTBM' 'ISEG' '13' space 'PHY.INV.VALUE' space space space space space space space space SPACE t_fieldcat 'R' 'C',
9 'DIFFQTY' 'MENGE' 'ISEG' '13' space 'DIFF.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
10 'DIFFVALUE' 'WRTZL' 'ISEG' '13' space 'DIFF.INV.VALUE' space space space space space space space space SPACE t_fieldcat SPACE 'P',
11 'BUDAT' 'BUDAT' 'ISEG' '18' space 'CORRECTED DATE' space space space space space space space space SPACE t_fieldcat 'C' 'C',
12 'GRTXT' 'GRTXT' 'ISEG' '18' space 'REASON' space space space space space space space space SPACE t_fieldcat 'L' 'L',
13 'REAS' 'REAS' 'ISEG' '18' space 'AUTH.BY' space space space space space space space space SPACE t_fieldcat 'C' 'C'.
x_layout-zebra = 'X'.
perform set_top_page_heading using t_heading t_event.
perform set_events using t_event.
perform get_subtotals.
w_status = ''.
w_repid = sy-repid.
w_comm = 'USER_COMMAND'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = t_fieldcat
i_Callback_top_of_page = 'Top-of-page'
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
tables
t_outtab = ITS1
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
ENDFORM.
FORM set_fieldcat2 USING
p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
p_subtot
t_fieldcat TYPE slis_t_fieldcat_alv
P_JUST
P_FTYPE.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-hotspot = p_hotspot.
wa_fieldcat-checkbox = p_checkbox.
wa_fieldcat-icon = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
wa_fieldcat-t_subtot = p_subtot.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
IF NOT P_JUST IS INITIAL.
WA_FIELDCAT-JUST = P_JUST.
ENDIF.
IF NOT p_edit IS INITIAL.
wa_fieldcat-Input = 'X'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-do_sum = 'x'.
wa_fieldcat-p_subtot = 'x'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
======================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_heading.
ENDFORM.
form set_top_page_heading using t_heading type slis_t_listheader
t_events type slis_t_event.
data: x_heading type slis_listheader,
x_event type line of slis_t_event.
Report title
clear t_heading[].
clear x_heading.
x_heading-typ = 'H'.
x_heading-info = 'PHYSICAL INVENTORY AUDIT REPORT'.
append x_heading to t_heading.
Plant Name
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'PLANT : '.
x_heading-info = PLANT.
append x_heading to t_heading.
IF DATE2 = '00.00.0000'.
CONCATENATE DATE1 'to' DATE1 INTO DT SEPARATED BY SPACE.
ELSE.
CONCATENATE DATE1 'to' DATE2 INTO DT SEPARATED BY SPACE.
ENDIF.
X_heading-TYP = 'S'.
X_heading-key = 'PERIOD :'.
X_heading-INFO = DT.
APPEND x_heading TO t_heading.
Control Date
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'CONTROL NO. :'.
x_heading-info = ' ASDFADDFAAS DATE : 11.04.2007'.
append x_heading to t_heading.
Control date
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'CONTROL DATE : '.
x_heading-info = ''.
append x_heading to t_heading.
Time of execution
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'DATE : '.
write sy-DATUM to x_heading-info.
append x_heading to t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-form = 'TOP_OF_PAGE'.
append x_event to t_events.
endform.
FORM get_subtotals.
CLEAR lv_sort.
lv_sort-fieldname = 'MENGE'.
lv_sort-up = 'X'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
*lv_sort-fieldname = 'MENGE'.
*lv_sort-tabname = 'ITS1'.
*lv_sort-subtot = 'X'.
*APPEND lv_sort TO t_sort.
lv_sort-fieldname = 'WRTZL'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
lv_sort-fieldname = 'BUCHM'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
lv_sort-fieldname = 'WRTBM'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
lv_sort-fieldname = 'DIFFQTY'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
lv_sort-fieldname = 'DIFFVALUE'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
ENDFORM.
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
endform.
PLZ HELP ME and definately get rewarded.hi,
how did u declared ur internal table?
Declare a dummy field in your internal table to trigger subtotal text event.
TYPES: BEGIN OF ty_ekpo,
lifnr TYPE ekko-lifnr, "vendor number
ebeln TYPE ekko-ebeln, "purchase document number
ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document
matnr TYPE ekpo-matnr, "Material Number
bukrs TYPE ekpo-bukrs, "Company Code
werks TYPE ekpo-werks, "Plant
d, "Dummy field to fire the Subtotal text event
END OF ty_ekpo.
Prepare field catalog for that dummyfield also and set attributes like below
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'D'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-ref_fieldname = 'NETPR'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-no_out = 'X'.
APPEND wa_fcat TO it_fcat.
Fill sortinfo table as follows
wa_sort-spos = 1.
wa_sort-fieldname = 'LIFNR'.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-spos = 2.
wa_sort-fieldname = 'D'.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO it_sort.
fill the event table
wa_event-name = 'SUBTOTAL_TEXT'. "--> this event is used to trigger subtotal text
wa_event-form = 'SUBTOTAL'.
APPEND wa_event TO it_event.
*& Form subtotal
FORM subtotal USING i_listhead STRUCTURE wa_ekpo i_subtotal TYPE slis_subtot_text.
READ TABLE it_sort INTO wa_sort WITH KEY fieldname = 'D'.
IF sy-subrc = 0.
IF i_subtotal-criteria = 'D'.
i_subtotal-display_text_for_subtotal = 'Sub total'.
ENDIF.
ENDIF.
ENDFORM. "subtotal
Thanks & REgards -
URGENT:-Regarding sub-total in alv code
Hi,
i had made dis report and it is working fine but now i want to add the sub total feature in dis report as it is the new requierment of report.
plzz help me out by providing the code of sub-total feature in dis report .
Help will be definately rewarded. here is d code of report:-
TABLES: ISEG,MARA.
TYPE-POOLS : SLIS.
DATA : DATE1(15) TYPE C,
DATE2(15) TYPE C,
TITLE(65) TYPE C,
DT(25) TYPE C.
DATA : ITEVENT TYPE SLIS_T_EVENT.
DATA: lv_sort TYPE slis_sortinfo_alv,
t_sort type slis_t_sortinfo_alv.
DATA : repid LIKE sy-repid.
INTERNAL TABLE FOR INVENTORY STOCK *****************
DATA: BEGIN OF ITS1 OCCURS 0,
MATNR LIKE ISEG-MATNR,
ITEMID(6) TYPE C,
MEINS LIKE ISEG-MEINS,
MENGE LIKE ISEG-MENGE,
WRTZL LIKE ISEG-WRTZL,
BUCHM LIKE ISEG-BUCHM,
WRTBM LIKE ISEG-WRTBM,
WERKS LIKE ISEG-WERKS,
BUDAT LIKE ISEG-BUDAT,
ZLDAT LIKE ISEG-ZLDAT,
MTART LIKE MARA-MTART,
ITEMDESC LIKE MAKT-MAKTX,
DIFFQTY LIKE ISEG-BUCHM,
DIFFVALUE LIKE ISEG-WRTBM,
GRUND LIKE ISEG-GRUND,
GRTXT LIKE T157E-GRTXT,
BWART LIKE T157E-BWART,
REAS TYPE C LENGTH 15,
END OF ITS1.
data: t_heading type slis_t_listheader.
SELECTION-SCREEN BEGIN OF BLOCK PAR1 WITH FRAME TITLE TEXT-001.
*SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
*********PARAMETERS*********
PARAMETERS : PLANT LIKE ISEG-WERKS OBLIGATORY.
*********SELECTION SCREEN OPTIONS*********
SELECT-OPTIONS : R_DATE FOR ISEG-BUDAT OBLIGATORY NO-EXTENSION,
M_TYPE FOR MARA-MTART,
IT_M FOR MARA-MATNR.
*********DEFINING VARIABLES*********
SELECTION-SCREEN END OF BLOCK par1.
CONCATENATE R_DATE-LOW6(2) '.' R_DATE-LOW4(2) '.' R_DATE-LOW+0(4) INTO DATE1.
CONCATENATE R_DATE-HIGH6(2) '.' R_DATE-HIGH4(2) '.' R_DATE-HIGH+0(4) INTO DATE2.
TOP-OF-PAGE.
PERFORM PG_HEADER.
START-OF-SELECTION.
SELECT AMATNR AMEINS AMENGE AWRTZL ABUCHM AWRTBM AWERKS ABUDAT AZLDAT BMTART AGRUND CBWART
FROM ISEG AS A INNER JOIN MARA AS B ON BMATNR = AMATNR
INNER JOIN MSEG AS C ON AMBLNR = CMBLNR
INTO CORRESPONDING FIELDS OF TABLE ITS1 WHERE BMATNR = AMATNR AND BMEINS = AMEINS AND AWERKS = PLANT AND ABUDAT IN R_DATE AND BMTART IN M_TYPE AND BMATNR IN IT_M.
SORT ITS1 BY MTART.
LOOP AT ITS1.
ITS1-ITEMID = ITS1-MATNR+12(6).
ITS1-DIFFQTY = ITS1-MENGE - ITS1-BUCHM.
ITS1-DIFFVALUE = ITS1-WRTZL - ITS1-WRTBM.
SELECT SINGLE MAKTX FROM MAKT INTO ITS1-ITEMDESC WHERE MATNR = ITS1-MATNR.
SELECT SINGLE GRTXT INTO ITS1-GRTXT FROM T157E WHERE GRUND = ITS1-GRUND AND SPRAS = 'E' AND BWART = ITS1-BWART.
MODIFY ITS1.
ENDLOOP.
PERFORM PRN_SMSTOCK_ALV.
WRITING DATA FROM D TABLES**********
FORM PG_HEADER.
WRITE : 'INVENTORY REPORT PLANT : ', PLANT.
ENDFORM.
*& Form PRN_SMSTOCK_ALV
text
--> p1 text
<-- p2 text
form PRN_SMSTOCK_ALV .
data: w_title type lvc_title,
w_repid type syrepid,
w_comm type slis_formname,
w_status type slis_formname,
x_layout type slis_layout_alv,
t_event type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv,
t_subtot TYPE slis_t_sortinfo_alv,
subtot LIKE LINE OF t_subtot.
refresh t_fieldcat.
refresh t_event.
refresh t_sort.
clear x_layout.
clear w_title.
perform set_fieldcat2 using:
1 'MTART' 'MTART' 'MARA' '15' space 'MATERIAL TYPE' space space space space space space space space SPACE t_fieldcat 'L' 'L',
2 'ITEMID' 'ITEMID' 'MARA' '7' space 'ITEM ID' space space space space space space space space SPACE t_fieldcat 'R' 'C',
3 'ITEMDESC' 'MAKTX' 'MAKT' '25' space 'MATERIAL DESCRIPTION' space space space space space space space space SPACE t_fieldcat 'L' 'C',
4 'MEINS' 'MEINS' 'MARA' '5' space 'UOM' space space space space space space space space SPACE t_fieldcat 'C' 'C',
5 'MENGE' 'MENGE' 'ISEG' '13' space 'ORG.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
6 'WRTZL' 'WRTZL' 'ISEG' '13' space 'ORG.INV.VALUE' space space space space space space space space SPACE t_fieldcat 'R' 'C',
7 'BUCHM' 'BUCHM' 'ISEG' '13' space 'PHY.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
8 'WRTBM' 'WRTBM' 'ISEG' '13' space 'PHY.INV.VALUE' space space space space space space space space SPACE t_fieldcat 'R' 'C',
9 'DIFFQTY' 'MENGE' 'ISEG' '13' space 'DIFF.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
10 'DIFFVALUE' 'WRTZL' 'ISEG' '13' space 'DIFF.INV.VALUE' space space space space space space space space SPACE t_fieldcat SPACE 'P',
11 'BUDAT' 'BUDAT' 'ISEG' '18' space 'CORRECTED DATE' space space space space space space space space SPACE t_fieldcat 'C' 'C',
12 'GRTXT' 'GRTXT' 'ISEG' '18' space 'REASON' space space space space space space space space SPACE t_fieldcat 'L' 'L',
13 'REAS' 'REAS' 'ISEG' '18' space 'AUTH.BY' space space space space space space space space SPACE t_fieldcat 'C' 'C'.
x_layout-zebra = 'X'.
perform set_top_page_heading using t_heading t_event.
perform set_events using t_event.
w_status = ''.
w_repid = sy-repid.
w_comm = 'USER_COMMAND'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = t_fieldcat
i_Callback_top_of_page = 'Top-of-page'
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
tables
t_outtab = ITS1
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
ENDFORM.
FORM set_fieldcat2 USING
p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
p_subtot
t_fieldcat TYPE slis_t_fieldcat_alv
P_JUST
P_FTYPE.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-hotspot = p_hotspot.
wa_fieldcat-checkbox = p_checkbox.
wa_fieldcat-icon = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
IF NOT P_JUST IS INITIAL.
WA_FIELDCAT-JUST = P_JUST.
ENDIF.
IF NOT p_edit IS INITIAL.
wa_fieldcat-Input = 'X'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-do_sum = 'x'.
wa_fieldcat-checkbox = 'x'.
wa_fieldcat-hotspot = 'x'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
======================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_heading.
ENDFORM.
form set_top_page_heading using t_heading type slis_t_listheader
t_events type slis_t_event.
data: x_heading type slis_listheader,
x_event type line of slis_t_event.
Report title
clear t_heading[].
clear x_heading.
x_heading-typ = 'H'.
x_heading-info = 'PHYSICAL INVENTORY AUDIT REPORT'.
append x_heading to t_heading.
Plant Name
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'PLANT : '.
x_heading-info = PLANT.
append x_heading to t_heading.
IF DATE2 = '00.00.0000'.
CONCATENATE DATE1 'to' DATE1 INTO DT SEPARATED BY SPACE.
ELSE.
CONCATENATE DATE1 'to' DATE2 INTO DT SEPARATED BY SPACE.
ENDIF.
X_heading-TYP = 'S'.
X_heading-key = 'PERIOD :'.
X_heading-INFO = DT.
APPEND x_heading TO t_heading.
Control Date
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'CONTROL NO. :'.
x_heading-info = ' ASDFADDFAAS DATE : 11.04.2007'.
append x_heading to t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-form = 'TOP_OF_PAGE'.
append x_event to t_events.
endform.
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
endform.
Edited by: ric .s on Jan 29, 2008 5:21 AMHi,
U can do subtotal for a field based on some other field in ur ALV report using slis_t_sortinfo_alv.
see the sample code below...
data: int_sort TYPE slis_t_sortinfo_alv,
fs_sort TYPE slis_sortinfo_alv.
Sort the output based on ORG UNIT.
CLEAR fs_sort.
fs_sort-fieldname = 'ORGEH'.
fs_sort-subtot = 'X'.
fs_sort-up = 'X'.
APPEND fs_sort TO int_sort.
perform f_alv_catsfieldcat.
Fieldcat calculates the sum for SMPCNT field.
FORM f_alv_catsfieldcat.
DATA: loc_fieldcat TYPE slis_fieldcat_alv.
DEFINE define_field.
clear loc_fieldcat.
loc_fieldcat-fieldname = &1.
loc_fieldcat-seltext_l = &2.
loc_fieldcat-key = &3.
loc_fieldcat-outputlen = &4.
loc_fieldcat-do_sum = &5.
append loc_fieldcat to int_fieldcat.
END-OF-DEFINITION.
REFRESH int_fieldcat.
CLEAR int_fieldcat.
define_field 'PERNR' text-029 'X' '8' ''.
define_field 'ENAME' text-030 '' '40' ''.
define_field 'KOSTL' text-037 '' '10' ''.
define_field 'SMPCNT' text-040 '' '' 'X'.
endform.
Then call REUSE_ALV-GRID_DISPLAY with ur internal table with int_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'TOP_OF_PAGE'
it_sort = int_sort
i_callback_pf_status_set = 'F_PF_STATUS_SET'
i_callback_user_command = 'F_USER_COMMAND'
it_fieldcat = int_fieldcat
i_save = 'X'
TABLES
t_outtab = int_outputcpy
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE / 'error'.
ENDIF.
Hope it will help u..
Reward points if helpful
Cheers,
Shanthi
Edited by: shanthi ps on Jan 29, 2008 5:37 AM
Edited by: shanthi ps on Jan 29, 2008 5:38 AM -
Urgent : Query on select statement!!
Hi All,
i am trying to get the customer number from VBPA table into my work area based on vbeln and parvw values. but it is giving me an sysubrc value is 4.
here is my code :
select single kunnr into wa_i_vbpa
from vbpa
where vbeln = p_i_vbeln
and parvw = 'SP'.
Kindly check and let me know whether this is correct or not? if not, please correct it and send it to me back.
Thanks in advance.Hi,
Please try this instead.
select single kunnr into wa_i_vbpa
from vbpa
where vbeln = p_i_vbeln
and parvw = 'AG'.
Regards,
Ferry Lianto -
Select statement issue--urgent
Hi All,
i need information regarding below select statement.
SELECT ebelp
ebeln
vgabe
SUM( menge ) AS menge
shkzg
FROM ekbe
INTO TABLE t_ekbe
WHERE ebeln EQ t_documents-ebeln
AND ebelp EQ t_documents-ebelp
AND ( vgabe EQ c_1
OR vgabe EQ c_2 )
GROUP by ebelp ebeln vgabe shkzg.
I am working 4.5b version now.All the data declartion is correct.This select statement goes to Dump .when ever data is selected before the select statment.
let me any other choices to do same.its urgent.
Thanks,
ArnaldHi...Arnald..
Try this way... Runtime error may be bcoz of the Order of fields....
types : begin of st_ekbe,
EBELN TYPE EKBE-EBELN,
EBELPTYPE EKBE-EBELP,
VGABE TYPE EKBE-VGABE,
SHKZG TYPE EKBE-SHKZG,
MENGE TYPE EKBE-MENGE,
end of st_ekbe.
DATA: T_EKBE TYPE TABLE OF ST_EKBE.
SELECT
ebeln
ebelp
vgabe
shkzg
SUM( menge )
FROM ekbe
INTO TABLE t_ekbe
WHERE ebeln EQ t_documents-ebeln
AND ebelp EQ t_documents-ebelp
AND ( vgabe EQ c_1
OR vgabe EQ c_2 )
GROUP by ebeln ebelp vgabe shkzg.
<b>Reward if Helpful</b> -
Is `WHERE` clause pointless inside a sub-select?
WHERE is part of the definition of a sub-select:
[WITH [<calc-clause> ...]]
SELECT [<axis-spec> [, <axis-spec> ...]]
FROM [<identifier> | (< sub-select-statement >)]
[WHERE <slicer>]
[[CELL] PROPERTIES <cellprop> [, <cellprop> ...]]
< sub-select-statement > :=
SELECT [<axis-spec> [, <axis-spec> ...]]
FROM [<identifier> | (< sub-select-statement >)]
[WHERE <slicer>]I understand that a subselect does not reduce dimensionality or set context.
If overall context of a script is not driven via a sub-select then is there ever a point in using this WHERE clause in the subselect?
An example in Adventure Works:
SELECT
[Measures].[Order Count] ON 0
[Geography].[Country] * [Product].[Category] ON 1
FROM
SELECT
[Geography].[Country].[Australia] ON 0
FROM [Adventure Works]
WHERE
[Product].[Category].[Bikes]Hi WhyTheQ,
According to your description, you want to know if the Where clause is working when the main select statement is not driven via the sub-select. Right?
In MDX, Where clause is used for defining slicer axis so that only the data intersecting the with the specified member will be returned. It will work in the sub-select to restrict the data. However, the return result from sub-select should match
the set on your axis. In this scenario, your sub-select returns an aggregation value of a dimension member, but in your main select row level expects a tuple set. So your can't get the result and it will throw error.
Reference:
Specifying the Contents of a Slicer Axis (MDX)
Best Regards,
Simon Hou
TechNet Community Support -
* table name in the select statements
Hi,
I have come across a select Statement as below.
Select * into *nast from nast where <conditions>.. End select.
what does this *nast represents and when is it used. why do we need to call a Table with *<Table Name>
Kind Regards,
Ushahi,
select statement will always points to a database table so we have to give database table name and it gets data from that table. for storing that data we have to use internal tables must have same structure of database table.
so select statement has the following form as........
select * from [dbtable] into table [internal table]
endselect.
in sap select will act as a loop so that we hav to use end sleect. select has different varities in sap. for some types no need of end select.
for ex:
select single *
select * ..................... into table [internal table name].....
if helpful reward some points.
with regards,
suresh. -
Order of records in o/p of select statement
Hi all
I have doubt regarding the select statement. I need to execute a select statement (with out any order ie with out "order by") which searchs a table. I want to know whether in any
circumstances the order of the records of the select statement is different.
sample select statement which I need to execute
select emp_no from emplyees where designation = 'programer'
in one word order of records of in the o/p of a select statement will be unique ?
(provided same query same, table,)
can u plz quote the link to get more information
regards
RenjithHi,
YES, you can
Do Order By Without Using Order By Clause
in your select statement.
I assume that you have unique data ( e.g. emp_no in Emp Table ) and you you do not want to use Order by clause.
Solution 1:
Select Emp_no
from Emp
group by Emp_no;
the o/p will be in the sorted in the Ascending order.
Solution 2: ( Only for columns holding Numeric Values )
Select Emp_No
From Emp
Where 99999 - Emp_no in ( Select 99999 - Emp_no from Emp );
Again this will sort the result will be in the Descending Order. you can use any big number instead of 99999 but it should be greater than Emp_no value.
Note: You Should only use this method on not very large tables coz of performance issue.
Hope this will solve your problem.
Any Comment on this, any body.
Thanks and Regards
There is always a solution to the problem, And if there is no solution of a problem then problem is not a problem. -
Insert Using SELECT & Sub-SELECT
Hi All,
I am trying to insert records into a table using SELECT statement. The SELECT statement has a Sub-SELECT statement as follows:
INSERT INTO table1(c1,c2,c3,c4,c5)
SELECT c1,c2, (SELECT MAX(C3)+a1.c3
FROM table1
WHERE c1 = var1
AND c2 = a1.c2
GROUP BY c3),c4,c5,
FROM table1 a1
WHERE c1 = var1
The above works fine when run from SQL*PLUS but gives compilation error when included in PL/SQL pacakge.
I am using Oracle 8.1.7.
Could you any one please tell me if I have missed something?
Thanks,
Satyen.In 8i, you will need to use dynamic SQL to execute this statement because the PL/SQL parser does not understand all SQL syntax (including SELECT in a column list).
execute immediate
'INSERT INTO table1(c1,c2,c3,c4,c5)' ||
' SELECT c1, c2, (SELECT MAX(C3)+a1.c3 FROM table1 WHERE c1 = :var1 AND c2 = a1.c2 GROUP BY c3), c4, c5' ||
' FROM table1 a1 WHERE c1 = :var1' using var1, var1; -
Select statement in a sub routine(For Sapscript)
Hi,
M unable to write select statement for my reqirement in Sap-script in Sub routine.
My requirement is 1)"Your correspondent for quality" in main window of my form.
For dis rule is as below
"Get the 'changed by' value resord in table QCPR field AENDERER.For the same value found in tabe USR21 fiels BNAME,pick up the PERSUNUM value.For dis PERSUNUM value, found in ADRP feild NAME_TEXT the value for "Your Correspondent for Quality".
2) For this PERSUNUM value found in ADCP-TEL_NUMBER the vakue for "Ph".
3)For this PERSUNUM value found in ADCP-FAX_NUMBER the vakue for "FAX".
4For this PERSUNUM value found in ADR6-SMTP_ADDR the vakue for "EMAIL".
Please help me out it's urgent for me.I wil b waiting 4 ur reply.READ TABLE in_par WITH KEY 'QCPR-AENDERER'.
CHECK sy-subrc = 0.
MOVE in_par-value TO V_aenderer
. READ TABLE in_par WITH KEY 'USR21-BNAME.
CHECK sy-subrc = 0.
MOVE in_par-value TO V_bname
SELECT SINGLE persnumber addrnumber
INTO wa_usr21-persnumber wa_usr21-addrnumber
FROM usr21
WHERE bname = V_bname
and <b>check field for this</b> = V_aenderer.
CHECK sy-subrc = 0.
SELECT SINGLE tel_number fax_number
INTO adcp-tel_number adcp-fax_number
FROM adcp
WHERE addrnumber = usr21-addrnumber
AND persnumber = usr21-persnumber.
CHECK sy-subrc = 0.
READ TABLE out_par WITH KEY 'ADCP-TEL_NUMBER'.
CHECK sy-subrc = 0.
out_par-value = adcp-tel_number.
MODIFY out_par INDEX sy-tabix.
READ TABLE out_par WITH KEY 'ADCP-FAX_NUMBER'.
CHECK sy-subrc = 0.
out_par-value = adcp-fax_number.
MODIFY out_par INDEX sy-tabix.
SELECT SINGLE smtp_addr
INTO adr6-smtp_addr
FROM adr6
WHERE addrnumber = usr21-addrnumber
AND persnumber = usr21-persnumber.
READ TABLE out_par WITH KEY 'ADR6-SMTP_ADDR'.
CHECK sy-subrc = 0.
out_par-value = adr6-smtp_addr.
MODIFY out_par INDEX sy-tabix.
Regards -
Urgent, SELECT statement results in error
hi all, this is very urgent, could you guys have a look at my SELECT statement?
SELECT vk~kunnr "customer no
vk~vbeln "sales order no
vk~audat "date
vk~vbtyp "SD DOCUMENT CATEGORY
vk~knumv "lwk
vp~kwmeng "qty
vp~matnr "material no
vp~posnr "LINE ITEM
vd~bstkd "PURCHASE ORDER NO
* kv~kwert "lwk
FROM vbak AS vk
INNER JOIN vbap AS vp
ON vk~vbeln = vp~vbeln
INNER JOIN vbkd AS vd
ON vk~vbeln = vd~vbeln
* INNER JOIN konv AS kv
* ON kv~knumv = vk~knumv
INTO CORRESPONDING FIELDS OF TABLE it_so
WHERE vk~vkorg IN s_vkorg
AND vk~audat IN s_date
AND vk~kunnr IN s_kunnr
AND vp~matnr IN s_matnr
AND vd~bstkd IN s_bstkd
AND vk~vbeln IN s_vbeln
* AND kv~kschl = 'ZP00'
AND vk~vbtyp = 'C'.
The commented lines are the new additions that i want to add to the SELECT statement. But when i un-comment them, i get an error while activating my program. Error is as follows:
For pooled tables, cluster tables, and project views, JOIN is not allowed: "KONV".
Is there a way i can go around it?Hi,
look at this SAP note : 550043
Symptom
KEPM: dump 'MESSAGE_TYPE_X' during automatic planning method execution.
Other terms
KEPM MESSAGE_TYPE_X transform characteristic value
Reason and Prerequisites
This note is related only to cases, if dump 'MESSAGE_TYPE_X' is raising
during execution of planning method, for which is possible to define
transformation of characteristics values i.e. Copy, Forecast, Top-Down
distribution, Ratios and Customer Enhancement.
Dump is raising in case, if there was defined transformation of char.
values in parameter set definition for some characteristic. Later on,
this characteristic was removed from planning level definition but
characteristic wasn't removed from relevant customizing of transform
characteristic values before.
Solution
Please apply attached program correction.
Regards,
GSR. -
Delete statement that uses a sub-select with the statement in the cursor
Hi all,
How to write write a delete statement that uses a sub-select with the statement in the cursor?
CURSOR excluded_dates IS
SELECT TO_TIMESTAMP(report_parameter_value, in_date_format_mask)
INTO my_current_date_time
FROM report_parameters
WHERE report_parameters.report_parameter_id = in_report_parameter_id
AND report_parameters.report_parameter_group = 'DATE_TIME'
AND report_parameters.report_parameter_name = 'EXCLUDED_DATE';
OPEN excluded_dates;
LOOP
FETCH excluded_dates INTO my_excluded_date;
EXIT WHEN excluded_dates%NOTFOUND;
DELETE FROM edr_rpt_tmp_inclusion_table
WHERE TO_CHAR(date_time, 'mm/dd/yyyy') = TO_CHAR(my_excluded_date, 'mm/dd/yyyy');
END LOOP;
CLOSE excluded_dates;ThanksHi,
In such case I think is better to create a view an perform the delete using it. Example (using HR schema):
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> create or replace view v_employees as select * from employees where first_name like 'J%';
View created
SQL> select * from v_employees;
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
110 John Chen JCHEN 515.124.4269 28/09/1997 FI_ACCOUNT 8200,00 108 100
112 Jose Manuel Urman JMURMAN 515.124.4469 07/03/1998 FI_ACCOUNT 7800,00 108 100
125 Julia Nayer JNAYER 650.124.1214 16/07/1997 ST_CLERK 3200,00 120 50
127 James Landry JLANDRY 650.124.1334 14/01/1999 ST_CLERK 2400,00 120 50
131 James Marlow JAMRLOW 650.124.7234 16/02/1997 ST_CLERK 2500,00 121 50
133 Jason Mallin JMALLIN 650.127.1934 14/06/1996 ST_CLERK 3300,00 122 50
139 John Seo JSEO 650.121.2019 12/02/1998 ST_CLERK 2700,00 123 50
140 Joshua Patel JPATEL 650.121.1834 06/04/1998 ST_CLERK 2500,00 123 50
145 John Russell JRUSSEL 011.44.1344.429268 01/10/1996 SA_MAN 14000,00 0,40 100 80
156 Janette King JKING 011.44.1345.429268 30/01/1996 SA_REP 10000,00 0,35 146 80
176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24/03/1998 SA_REP 8600,00 0,20 149 80
177 Jack Livingston JLIVINGS 011.44.1644.429264 23/04/1998 SA_REP 8400,00 0,20 149 80
181 Jean Fleaur JFLEAUR 650.507.9877 23/02/1998 SH_CLERK 3100,00 120 50
186 Julia Dellinger JDELLING 650.509.3876 24/06/1998 SH_CLERK 3400,00 121 50
189 Jennifer Dilly JDILLY 650.505.2876 13/08/1997 SH_CLERK 3600,00 122 50
200 Jennifer Whalen JWHALEN 515.123.4444 17/09/1987 AD_ASST 4400,00 101 10
16 rows selected
SQL> delete from v_employees where hire_date >= to_date('01/06/1998', 'dd/mm/yyyy');
2 rows deleted
SQL> regards,
Maybe you are looking for
-
Hi, I have a fairly large song collection (>120Gb) kept in the iTune lib (iTunes lib on the primary c drive). The song files are kept in a external disc drive (windows pc). Somehow, I must have imported my CDs into the iTune lib more than once. I now
-
Looping message in Adapter Engine
Hello! We had a message which went fine in mapping (IDOC -> proxy) / integration engine (check flags in sxi_monitor) but stopped in Adapter Engine with status "To be delivered". No jammed queues or anything. It didnt help to restart the message, it
-
Report Generates Duplicate Rows
Each, I have a report which when generated and run as 9i report on Linux generates duplicate rows. Whereas the same report running on 6i client server works perfectly fine. Running against the exact same database. The report generates a delimited CSV
-
How can Manage Permissions for DB in Shared Services Security Mode
In shared services security mode, after provisioning users for Essbase applications, only can assign database calculation and filter access. How can I grant permissions "Access Databases" like in native mode?
-
Error: Microsoft Visual C++ Runtime Library Runtime Error! Program: C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe I work for a large government agency, and we are experiencing the above error, but we have the added complexity of Citrix (XenA