‎2008 Oct 25 10:12 AM
when i try to sort the table program is throwing dump
&----
*& Report ZDAN_DEMO_ALV
*&
&----
*&
*&
&----
REPORT zdan_demo_alv.
TYPE-POOLS: slis.
Types **********
*break hopflabap1.
TYPES: BEGIN OF ty_vbap,
matnr TYPE vbap-matnr, " material number
vbeln TYPE vbap-vbeln, " SO
posnr TYPE vbap-posnr, " SO item
arktx TYPE vbap-arktx, " text for so item
j_3apgnr TYPE vbap-j_3apgnr, " grid number
KWMENG TYPE vbap-KWMENG, " Quantity
zmeng TYPE vbap-zmeng, " target quantity
END OF ty_vbap.
*
TYPES : BEGIN OF ty_vbep,
j_3asize TYPE vbep-j_3asize, " grid value
vbeln1 TYPE vbep-vbeln, " SO
posnr1 TYPE vbep-posnr, " SO item
END OF ty_vbep.
TYPES : BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln,
AUART TYPE vbak-AUART, " Document Type
END OF ty_vbak.
TYPES : BEGIN OF ty_final,
matnr TYPE vbap-matnr,
posnr TYPE vbap-posnr,
arktx TYPE vbap-arktx,
j_3apgnr TYPE vbap-j_3apgnr,
KWMENG TYPE vbap-KWMENG,
vbeln TYPE vbap-vbeln,
j_3asize TYPE vbep-j_3asize,
vbeln1 TYPE vbep-vbeln,
posnr1 TYPE vbep-posnr,
AUART TYPE vbak-AUART,
END OF ty_final.
Data **********
DATA : it_vbap TYPE TABLE OF ty_vbap,
wa_vbap LIKE LINE OF it_vbap,
it_vbep TYPE TABLE OF ty_vbep,
wa_vbep LIKE LINE OF it_vbep,
it_vbak TYPE TABLE OF ty_vbak,
wa_vbak LIKE LINE OF it_vbak,
it_final TYPE TABLE OF ty_final,
wa_final LIKE LINE OF it_final.
DATA : it_fclog TYPE slis_t_fieldcat_alv,
wa_fclog LIKE LINE OF it_fclog,
it_sort TYPE slis_t_sortinfo_alv,
wa_sort LIKE LINE OF it_sort,
gd_layout TYPE slis_layout_alv,
gd_print TYPE slis_print_alv,
gd_repid LIKE sy-repid,
gt_events TYPE slis_t_event.
*break hopflabap1.
SELECTION-SCREEN BEGIN OF BLOCK sodisp WITH FRAME TITLE text-001.
PARAMETERS : matnr TYPE vbap-matnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK sodisp.
START-OF-SELECTION.
PERFORM data_retv.
PERFORM fclog.
PERFORM disp_rpt.
*break hopflabap1.
&----
*& Form data_retv
&----
text
----
FORM data_retv.
SELECT matnr posnr arktx j_3apgnr zmeng vbeln
*FROM vbap INTO wa_vbap WHERE matnr EQ matnr.
*
*SELECT vbeln j_3asize
*FROM vbep INTO table it_vbep
for all entries in it_vbap
where vbeln = it_vbap-vbeln and posnr = it_vbap-posnr.
*
ENDSELECT.
*
*loop at it_vbap into wa_vbap.
*"move all the data of wa_vbap into wa_final
*"since you are not using full key you may get more than one record
*loop at it_vbep INTO wa_vbep Where vbeln1 = it_vbap-vbeln and posnr1 = it_vbep-posnr1.
*
"move the information from wa_vbep to wa_final
*endloop.
*append wa_final to it_final.
*clear wa_final.
*endloop.
*break hopflabap1.
SELECT matnr vbeln posnr arktx j_3apgnr KWMENG
FROM vbap
INTO TABLE it_vbap
WHERE matnr EQ matnr.
SELECT j_3asize vbeln posnr
FROM vbep
INTO TABLE it_vbep
FOR ALL ENTRIES IN it_vbap
WHERE vbeln EQ it_vbap-vbeln AND posnr = it_vbap-posnr.
*break hopflabap1.
SELECT vbeln AUART
FROM vbak
INTO TABLE it_vbak
FOR ALL ENTRIES IN it_vbap
WHERE vbeln EQ it_vbap-vbeln.
LOOP AT it_vbap INTO wa_vbap.
LOOP AT it_vbep INTO wa_vbep.
LOOP AT it_vbak INTO wa_vbak.
READ TABLE it_vbak INTO wa_vbak with key vbeln = wa_vbap-vbeln.
wa_final-matnr = wa_vbap-matnr.
wa_final-vbeln = wa_vbap-vbeln.
wa_final-posnr = wa_vbap-posnr.
wa_final-arktx = wa_vbap-arktx.
wa_final-j_3asize = wa_vbep-j_3asize.
wa_final-j_3apgnr = wa_vbap-j_3apgnr.
wa_final-KWMENG = wa_vbap-KWMENG.
wa_final-AUART = wa_vbak-AUART.
wa_final-BMENG = wa_vbep-BMENG.
wa_final-vbeln1 = wa_vbep-vbeln1.
wa_final-posnr1 = wa_vbep-posnr1.
*break hopflabap1.
ENDLOOP.
ENDLOOP.
APPEND wa_final TO it_final.
*break hopflabap1.
ENDLOOP.
sort it_final by vbeln posnr j_3asize.
ENDFORM. "data_retv
&----
*& Form disp_rpt
&----
text
----
FORM disp_rpt.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
is_print = gd_print
i_callback_pf_status_set = 'SET_STATUS'
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = gd_layout
it_fieldcat = it_fclog[]
it_sort = it_sort[]
i_save = 'X'
IT_EVENTS = GT_EVENTS[]
TABLES
t_outtab = it_final[].
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. " DISPLAY_ALV_REPORT
&----
*& Form fclog
&----
text
----
FORM fclog.
wa_sort-fieldname = 'VBELN'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'POSNR'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'J_3ASIZE'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
wa_fclog-fieldname = 'MATNR'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Material Num'.
wa_fclog-outputlen = 15.
wa_fclog-col_pos = 2.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = ' VBELN'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'SO'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 3.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'POSNR '.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'SO Item'.
wa_fclog-outputlen = 15.
wa_fclog-col_pos = 4.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'ARKTX'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Description'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 7.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'J_3ASIZE'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Grid Value'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 5.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'J_3APGNR'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Grid Number'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 6.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'KWMENG'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Quantity'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 8.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'AUART'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Document Type'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 9.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
ENDFORM. "fclog
‎2008 Oct 25 10:28 AM
‎2008 Oct 25 10:36 AM
the current prog detected a situation which really should not occur. therefore a termination with a short dump was triggered on purpose by the keyword MESSAGE ( type x)
‎2008 Oct 25 11:18 AM
population of your selects and the logic is really confusing. i am not sure what is out come you want..i just modified your code a little. just check it once.
for your case one select is sufficient.but you are using 3 selects.
REPORT zalv_grid.
TYPE-POOLS : slis.
"there is lot of confusion in your code
"especially the data population
"include the fields what ever you want
"in the t_final defintion
"i just declared the fields to show an example
TYPES: BEGIN OF t_final ,
vbeln TYPE vbap-vbeln,
auart TYPE vbak-auart,
posnr TYPE vbap-posnr,
matnr TYPE vbap-matnr,
arktx TYPE vbap-arktx,
kwmeng TYPE vbap-kwmeng,
edatu TYPE vbep-edatu,
vrkme TYPE vbep-vrkme,
END OF t_final.
DATA:
it_fcat TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv,
it_final TYPE STANDARD TABLE OF t_final.
START-OF-SELECTION.
SELECT vbak~vbeln
vbak~auart
vbap~posnr
vbap~matnr
vbap~arktx
vbap~kwmeng
vbep~edatu
vbep~vrkme
FROM vbak JOIN vbap
ON vbak~vbeln = vbap~vbeln
JOIN vbep
ON vbap~vbeln = vbep~vbeln AND
vbap~posnr = vbep~posnr
INTO TABLE it_final.
END-OF-SELECTION.
wa_fcat-fieldname = 'VBELN'.
wa_fcat-outputlen = 10.
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-seltext_m = 'sales order'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'POSNR'.
wa_fcat-outputlen = 10.
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-seltext_m = 'sales Item'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-outputlen = 18.
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-seltext_m = 'material Number'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'ARKTX'.
wa_fcat-outputlen = 18.
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-seltext_m = 'material Desc'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'KWMENG'.
wa_fcat-outputlen = 18.
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-seltext_m = 'Qty'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'EDATU'.
wa_fcat-outputlen = 10.
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-seltext_m = 'Schedule.Date'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'VRKME'.
wa_fcat-outputlen = 10.
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-seltext_m = 'SalesUnit'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fcat
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
‎2008 Oct 25 11:45 AM
hi ,
i understand that there i slot of confusion in my code, i new to abap...
the code which you have given does not sort ...
output is comin for my prog when i remove the sort from fclog
but it is giving dump when i use sort field.
please help
‎2008 Oct 25 11:54 AM
try to include the sort logic.. and see. it is working for me..
wa_sort-fieldname = 'VBELN'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'POSNR'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.pass this it_sort to ALV it_sort option
‎2008 Oct 25 12:01 PM
try this program and you'll get an error....
REPORT zdan_demo_alv.
TYPE-POOLS: slis.
Types **********
*break hopflabap1.
TYPES: BEGIN OF ty_vbap,
matnr TYPE vbap-matnr, " material number
vbeln TYPE vbap-vbeln, " SO
posnr TYPE vbap-posnr, " SO item
arktx TYPE vbap-arktx, " text for so item
j_3apgnr TYPE vbap-j_3apgnr, " grid number
KWMENG TYPE vbap-KWMENG, " Quantity
zmeng TYPE vbap-zmeng, " target quantity
END OF ty_vbap.
*
TYPES : BEGIN OF ty_vbep,
j_3asize TYPE vbep-j_3asize, " grid value
vbeln1 TYPE vbep-vbeln, " SO
posnr1 TYPE vbep-posnr, " SO item
END OF ty_vbep.
TYPES : BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln,
AUART TYPE vbak-AUART, " Document Type
END OF ty_vbak.
TYPES : BEGIN OF ty_final,
matnr TYPE vbap-matnr,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
arktx TYPE vbap-arktx,
j_3apgnr TYPE vbap-j_3apgnr,
KWMENG TYPE vbap-KWMENG,
j_3asize TYPE vbep-j_3asize,
vbeln1 TYPE vbep-vbeln,
posnr1 TYPE vbep-posnr,
AUART TYPE vbak-AUART,
END OF ty_final.
Data **********
DATA : it_vbap TYPE TABLE OF ty_vbap,
wa_vbap LIKE LINE OF it_vbap,
it_vbep TYPE TABLE OF ty_vbep,
wa_vbep LIKE LINE OF it_vbep,
it_vbak TYPE TABLE OF ty_vbak,
wa_vbak LIKE LINE OF it_vbak,
it_final TYPE TABLE OF ty_final,
wa_final LIKE LINE OF it_final.
DATA : it_fclog TYPE slis_t_fieldcat_alv,
wa_fclog LIKE LINE OF it_fclog,
it_sort TYPE slis_t_sortinfo_alv,
wa_sort LIKE LINE OF it_sort,
gd_layout TYPE slis_layout_alv,
gd_print TYPE slis_print_alv,
gd_repid LIKE sy-repid,
gt_events TYPE slis_t_event.
*break hopflabap1.
SELECTION-SCREEN BEGIN OF BLOCK sodisp WITH FRAME TITLE text-001.
PARAMETERS : matnr TYPE vbap-matnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK sodisp.
START-OF-SELECTION.
PERFORM data_retv.
PERFORM fclog.
PERFORM blayout.
PERFORM disp_rpt.
*break hopflabap1.
&----
*& Form data_retv
&----
text
----
FORM data_retv.
SELECT matnr posnr arktx j_3apgnr zmeng vbeln
*FROM vbap INTO wa_vbap WHERE matnr EQ matnr.
*
*SELECT vbeln j_3asize
*FROM vbep INTO table it_vbep
for all entries in it_vbap
where vbeln = it_vbap-vbeln and posnr = it_vbap-posnr.
*
ENDSELECT.
*
*loop at it_vbap into wa_vbap.
*"move all the data of wa_vbap into wa_final
*"since you are not using full key you may get more than one record
*loop at it_vbep INTO wa_vbep Where vbeln1 = it_vbap-vbeln and posnr1 = it_vbep-posnr1.
*
"move the information from wa_vbep to wa_final
*endloop.
*append wa_final to it_final.
*clear wa_final.
*endloop.
*break hopflabap1.
SELECT matnr vbeln posnr arktx j_3apgnr KWMENG
FROM vbap
INTO TABLE it_vbap
WHERE matnr EQ matnr.
SELECT j_3asize vbeln posnr
FROM vbep
INTO TABLE it_vbep
FOR ALL ENTRIES IN it_vbap
WHERE vbeln EQ it_vbap-vbeln AND posnr = it_vbap-posnr.
*break hopflabap1.
SELECT vbeln AUART
FROM vbak
INTO TABLE it_vbak
FOR ALL ENTRIES IN it_vbap
WHERE vbeln EQ it_vbap-vbeln.
LOOP AT it_vbap INTO wa_vbap.
LOOP AT it_vbep INTO wa_vbep.
LOOP AT it_vbak INTO wa_vbak.
READ TABLE it_vbak INTO wa_vbak with key vbeln = wa_vbap-vbeln.
wa_final-matnr = wa_vbap-matnr.
wa_final-vbeln = wa_vbap-vbeln.
wa_final-posnr = wa_vbap-posnr.
wa_final-arktx = wa_vbap-arktx.
wa_final-j_3asize = wa_vbep-j_3asize.
wa_final-j_3apgnr = wa_vbap-j_3apgnr.
wa_final-KWMENG = wa_vbap-KWMENG.
wa_final-AUART = wa_vbak-AUART.
wa_final-BMENG = wa_vbep-BMENG.
wa_final-vbeln1 = wa_vbep-vbeln1.
wa_final-posnr1 = wa_vbep-posnr1.
*break hopflabap1.
ENDLOOP.
ENDLOOP.
APPEND wa_final TO it_final.
*break hopflabap1.
ENDLOOP.
*SORT it_final by vbeln posnr j_3asize.
ENDFORM. "data_retv
&----
*& Form disp_rpt
&----
text
----
FORM disp_rpt.
gd_repid = sy-repid .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
is_print = gd_print
i_callback_pf_status_set = 'SET_STATUS'
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = gd_layout
it_fieldcat = it_fclog[]
it_sort = it_sort[]
i_save = 'X'
IT_EVENTS = GT_EVENTS[]
TABLES
t_outtab = it_final[].
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. " DISPLAY_ALV_REPORT
*FORM blayout.
gd_layout-zebra = 'X'.
*gd_print-no_coverpage = 'X'.
*gd_print-no_print_listinfos = 'X'.
*gd_layout-info_fieldname = 'RCLR'.
*
**gd_layout-colwidth_optimize = 'X'.
*ENDFORM. " BUILD_LAYOUT
&----
*& Form fclog
&----
text
----
FORM fclog.
wa_sort-fieldname = 'VBELN'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'POSNR'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'J_3ASIZE'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
wa_fclog-fieldname = 'MATNR'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Material Num'.
wa_fclog-outputlen = 15.
wa_fclog-col_pos = 2.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = ' VBELN'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'SO'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 3.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'POSNR '.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'SO Item'.
wa_fclog-outputlen = 15.
wa_fclog-col_pos = 4.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'ARKTX'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Description'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 7.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'J_3APGNR'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Grid Number'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 6.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'KWMENG'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Quantity'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 8.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'J_3ASIZE'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Grid Value'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 5.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
wa_fclog-fieldname = 'AUART'.
wa_fclog-tabname = 'IT_FINAL'.
wa_fclog-seltext_m = 'Document Type'.
wa_fclog-outputlen = 20.
wa_fclog-col_pos = 9.
APPEND wa_fclog TO it_fclog.
CLEAR wa_fclog.
ENDFORM. "fclog
‎2008 Oct 25 12:21 PM
in my system i can't see J_3ASIZE and J_3APGNR thats the reason i excluded from your program.
which version are you using..? try to exclude them and see.
‎2008 Oct 25 12:26 PM
‎2008 Oct 25 12:33 PM
if you exclude then..it will be equivalent to the example mentioned above in my post. i am really confused with your selects. change the selects. follow the example mentioned