Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV program

Former Member
0 Likes
420

i have written a code below. i am facing problem in the select statement.

i want to all the data of it_vbap and it_vbep to be transferred to it_final, this code is giving some error.

kindly help. the main problem im facing in linking the fields of vbap and vbep

REPORT zdan_demo_alv12.

TYPE-POOLS: slis.

*break hopflabap1.

TYPES: BEGIN OF ty_vbap,

matnr TYPE vbap-matnr, " material number

posnr TYPE vbap-posnr, " SO item

arktx TYPE vbap-arktx, " text for so item

j_3apgnr TYPE vbap-j_3apgnr, " grid number

zmeng TYPE vbap-zmeng, " target quantity

vbeln TYPE vbap-vbeln, " SO

END OF ty_vbap.

*

TYPES : BEGIN OF ty_vbep,

j_3asize TYPE vbep-j_3asize,

vbeln1 TYPE vbep-vbeln,

posnr1 TYPE vbep-posnr,

END OF ty_vbep.

TYPES : BEGIN OF ty_final,

matnr TYPE vbap-matnr,

posnr TYPE vbap-posnr,

arktx TYPE vbap-arktx,

j_3apgnr TYPE vbap-j_3apgnr,

zmeng TYPE vbap-zmeng,

vbeln TYPE vbap-vbeln,

j_3asize TYPE vbep-j_3asize,

vbeln1 TYPE vbep-vbeln,

posnr1 type vbep-posnr,

END OF ty_final.

DATA : it_vbap TYPE TABLE OF ty_vbap ,

wa_vbap type ty_vbap ,

it_vbep TYPE TABLE OF ty_vbep ,

wa_vbep TYPE ty_vbep,

it_final TYPE TABLE OF ty_final ,

wa_final TYPE ty_final.

DATA : it_fclog TYPE slis_t_fieldcat_alv,

wa_fclog LIKE LINE OF it_fclog,

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.

SELECT matnr posnr arktx j_3apgnr zmeng vbeln

FROM vbap INTO wa_vbap WHERE matnr EQ matnr.

SELECT j_3asize

FROM vbep INTO wa_vbep where it_vbep-vbeln1 = vbeln.

  • loop at it_final INTO wa_final.

*

*

  • READ TABLE it_vbap INTO wa_final WITH KEY matnr = matnr.

  • READ TABLE it_vbep INTO wa_final WITH KEY posnr = it_vbep-posnr.

*

  • COLLECT wa_final INTO it_final.

  • endloop.

*break hopflabap1.

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_fclog-fieldname = 'MATNR'.

wa_fclog-tabname = 'IT_VBAP'.

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 = 'POSNR '.

wa_fclog-tabname = 'IT_VBAP'.

wa_fclog-seltext_m = 'SO Item'.

wa_fclog-outputlen = 15.

wa_fclog-col_pos = 3.

APPEND wa_fclog TO it_fclog.

CLEAR wa_fclog.

wa_fclog-fieldname = 'ARKTX'.

wa_fclog-tabname = 'IT_VBAP'.

wa_fclog-seltext_m = 'Description'.

wa_fclog-outputlen = 20.

wa_fclog-col_pos = 4.

APPEND wa_fclog TO it_fclog.

CLEAR wa_fclog.

wa_fclog-fieldname = 'J_3APGNR'.

wa_fclog-tabname = 'IT_VBAP'.

wa_fclog-seltext_m = 'Grid Number'.

wa_fclog-outputlen = 20.

wa_fclog-col_pos = 5.

APPEND wa_fclog TO it_fclog.

CLEAR wa_fclog.

wa_fclog-fieldname = ' ZMENG'.

wa_fclog-tabname = 'IT_VBAP'.

wa_fclog-seltext_m = 'Target quantity'.

wa_fclog-outputlen = 20.

wa_fclog-col_pos = 6.

APPEND wa_fclog TO it_fclog.

CLEAR wa_fclog.

wa_fclog-fieldname = ' VBELN'.

wa_fclog-tabname = 'IT_VBAP'.

wa_fclog-seltext_m = 'SO'.

wa_fclog-outputlen = 20.

wa_fclog-col_pos = 6.

APPEND wa_fclog TO it_fclog.

CLEAR wa_fclog.

wa_fclog-fieldname = 'J_3ASIZE'.

wa_fclog-tabname = 'IT_VBEP'.

wa_fclog-seltext_m = 'Grid Value'.

wa_fclog-outputlen = 20.

wa_fclog-col_pos = 6.

APPEND wa_fclog TO it_fclog.

CLEAR wa_fclog.

ENDFORM. "fclog

1 REPLY 1
Read only

Former Member
0 Likes
379

you can update the same thread. why are you opening the new thread for the same program.

When you are selecting you also select the common fields, so that you can use these and populate the final table.

change the definitions of the tables accordingly...

SELECT matnr posnr arktx j_3apgnr zmeng vbeln
FROM vbap INTO wa_vbap WHERE matnr EQ matnr.
SELECT vbeln j_3asize 
FROM vbep posnr INTO table it_vbep
for all entries in it_vbap
 where vbeln = it_vbap-vbeln and posnr = it_vbap-posnr.


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 vbeln = it_vbap-vbeln  and posnr = it_vbep-posnr. 

 "move the information from wa_vbep to wa_final
endloop.
append wa_final to it_final.
clear wa_final.
endloop.