Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

CALL transaction in ALV

Hi Experts,

I have created an ALV report which is working fine. now i have ot make it interactive but i am not getting where i have to add the code fr events etc. Requirements is whe User clicks on material it wil call MM03, when user click on Sales order it wil call VA03 wiht the corresponding values.

Below is the report created by me, can you please tell me where to add the code. I read so many threads in SDN but no one says where to write the interactive code, few gave a demo report but tht even not working fine. By those reports its nt clear to me where i have to call reuse alv events get FM or do i only need to put the user command in grid displya FM.

In my report i am using a perform for it_event which is for TOP of PAGE, please have a look on my existing report & answer accordingly.

&----


*& TABLES

&----


TABLES: AFKO, AFPO, AFVC, AFVV, T001W, VBEP.

TYPE-POOLS: slis.

&----


*& DATA DECLARATIONS

&----


DATA : t1 TYPE p ,

d1 TYPE i ,

age TYPE i ,

l_date type sy-datum,

i_date1 TYPE sy-datum,

i_time1 TYPE sy-uzeit.

DATA : v_repid LIKE sy-repid.

DATA : rem TYPE i.

&----


*& Internal Table declaration

&----


DATA : it_heading TYPE slis_t_listheader WITH HEADER LINE.

DATA : it_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA : lay TYPE slis_layout_alv.

DATA : it_sort_subtotal TYPE slis_t_sortinfo_alv WITH HEADER LINE.

DATA : it_event TYPE slis_t_event WITH HEADER LINE.

DATA : i_events TYPE slis_t_event,

w_events TYPE slis_alv_event.

DATA : BEGIN OF IT_AFVV OCCURS 0,

aplzl like afvv-aplzl,

aufpl like afvv-aufpl,

fsavd like afvv-fsavd,

vgw03 like afvv-vgw03,

END OF IT_AFVV.

DATA : BEGIN OF IT_AFVC OCCURS 0,

aufpl like afvc-aufpl,

werks like afvc-werks,

END OF IT_AFVC.

DATA : BEGIN OF IT_AFKO OCCURS 0,

aufnr like afko-aufnr,

plnbez like afko-plnbez,

maufnr like afko-maufnr,

aufpl like afko-aufpl,

END OF IT_AFKO.

DATA : BEGIN OF IT_VBEP OCCURS 0,

VBELN LIKE VBEP-VBELN,

POSNR LIKE VBEP-POSNR,

EDATU LIKE VBEP-EDATU,

END OF IT_VBEP.

DATA : BEGIN OF IT_AFPO OCCURS 0,

aufnr like afpo-aufnr,

kdauf like afpo-kdauf,

kdpos like afpo-kdpos,

pgmng like afpo-pgmng,

amein like afpo-amein,

matnr like afpo-matnr,

END OF IT_AFPO.

DATA : BEGIN OF IT_MARC OCCURS 0,

MATNR LIKE MARC-MATNR,

MATGR LIKE MARC-MATGR,

END OF IT_MARC.

DATA : BEGIN OF gt_final OCCURS 0,

matgr like marc-matgr,

vgw03 like afvv-vgw03,

fsavd like afvv-fsavd,

edatu type vbep-edatu,

item_no type i,

aufnr like afko-aufnr,

kdauf like afpo-kdauf,

kdpos like afpo-kdpos,

pgmng like afpo-pgmng,

amein like afpo-amein,

c_matnr like afpo-matnr,

c_maktx like makt-maktx,

matnr like afpo-matnr,

maktx like makt-maktx,

cut(1) TYPE c,

probs type Char40,

END OF gt_final.

&----


*& SELECTION SCREEN

&----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.

SELECT-OPTIONS : p_plant FOR t001W-werks OBLIGATORY .

SELECT-OPTIONS : p_date FOR AFVV-fsavd OBLIGATORY .

*SELECT-OPTIONS : p_rfgrp FOR afvc-rfgrp.

SELECT-OPTIONS : p_rfsch FOR afvc-rfsch.

SELECTION-SCREEN END OF BLOCK b1 .

&----


*& INITIALIZATION

&----


INITIALIZATION.

&----


*& AT SELECTION SCREEN

&----


AT SELECTION-SCREEN.

*--Validate plant

SELECT SINGLE * FROM t001w WHERE werks IN p_plant.

IF sy-subrc NE 0.

MESSAGE e001(319) WITH 'Plant does not Exist!'.

ENDIF.

&----


*& START OF SELECTION

&----


START-OF-SELECTION.

*--get data into internal table from database

PERFORM data_retrieve.

*--get data into final internal table after aging calculation.

PERFORM get_final.

*--get data from final internal table as per the radio button selected in selection screen

  • PERFORM selection_screen.

&----


*& END OF SELECTION

&----


END-OF-SELECTION.

*--display data in ALV form.

PERFORM data_display_alv.

&----


*& Form data_retrieve

&----


  • To Retrieve data from tables

----


FORM data_retrieve .

  • AFVV selection

SELECT aplzl aufpl fsavd vgw03

FROM AFVV

INTO TABLE it_afvv

WHERE fsavd IN p_date.

IF NOT it_afvv[] IS INITIAL.

  • afvc selection

SELECT aufpl werks

FROM AFVC

INTO TABLE it_afvc

FOR ALL ENTRIES IN it_afvv

WHERE aufpl EQ it_afvv-aufpl

AND aplzl EQ it_afvv-aplzl

AND werks IN p_plant

AND rfgrp EQ '3'

AND rfsch IN p_rfsch.

IF NOT it_afvc[] IS INITIAL.

  • afko selection

SELECT aufnr plnbez maufnr aufpl

FROM afko

INTO TABLE it_afko

FOR ALL ENTRIES IN it_afvc

WHERE aufpl EQ it_afvc-aufpl.

  • GROUP BY PLNBEZ AUFNR maufnr aufpl.

IF NOT it_afko[] IS INITIAL.

  • afpo selection

SELECT aufnr kdauf kdpos pgmng amein matnr

FROM afpo

INTO TABLE it_afpo

FOR ALL ENTRIES IN it_afko

WHERE aufnr EQ it_afko-aufnr.

  • SELECT aufnr matnr

  • FROM afpo

  • INTO TBALE it_afpo2

  • FOR all entries in it-afko

  • WHERE aufnr = maufnr.

IF NOT it_afpo[] IS INITIAL.

SELECT MATNR MATGR FROM MARC INTO TABLE IT_MARC

FOR ALL ENTRIES IN IT_AFPO

WHERE MATNR EQ IT_AFPO-MATNR.

SELECT VBELN POSNR EDATU FROM VBEP INTO TABLE IT_VBEP

FOR ALL ENTRIES IN IT_AFPO

WHERE VBELN EQ IT_AFPO-KDAUF

AND POSNR EQ IT_AFPO-KDPOS.

IF sy-subrc <> 0.

MESSAGE i001(319) WITH 'No Data exist for the given combination !' .

EXIT.

ENDIF.

endif.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " data_retrieve.

&----


*& Form ale_event_top_of_page

&----


  • Heading in ALV

----


FORM ale_event_top_of_page.

DATA l_date(10).

WRITE sy-datum TO l_date.

DATA : t_plant TYPE string.

PERFORM alv_heading

USING 'H' '' 'XYZ COMPANY LTD'.

PERFORM alv_heading

USING 'S' 'Title' sy-title.

PERFORM alv_heading

USING 'S' 'Date' l_date.

*****To display Plant range in ALV report if range selected

IF p_plant-high IS NOT INITIAL.

CONCATENATE p_plant-low 'To' p_plant-high INTO t_plant SEPARATED BY space.

ELSE.

MOVE p_plant-low TO t_plant.

ENDIF.

CONDENSE t_plant.

PERFORM alv_heading

USING 'S' 'Plant' t_plant.

*--for heading of ALV

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_heading[].

CLEAR it_heading[].

ENDFORM. " ALE_EVENT_TOP_OF_PAGE

&----


*& Form data_display_alv

&----


  • display data in ALV form

----


FORM data_display_alv.

DATA: v_repid LIKE sy-repid.

PERFORM alv_events USING 'TOP_OF_PAGE' 'ALE_EVENT_TOP_OF_PAGE'.

PERFORM alv_declare_key_fields.

PERFORM alv_layout.

PERFORM alv_it_sort_subtotal.

PERFORM event_get.

PERFORM alv_grid_display.

ENDFORM. " data_display_alv

&----


*& Form alv_events

&----


FORM alv_events USING name

form.

CLEAR it_event.

it_event-name = name.

it_event-form = form.

APPEND it_event.

ENDFORM. " alv_events

&----


*& Form alv_declare_key_fields

&----


  • Declaring fields to display in ALV

----


FORM alv_declare_key_fields .

PERFORM ale_field_catagory

USING '1' 'ITEM_NO' '' '' 'X' '' '' 'L' '' '' '' '' 'Item No.'.

PERFORM ale_field_catagory

USING '8' 'AUFNR' '' '' '' '' '' 'L' '' '' '' '' 'Order'.

PERFORM ale_field_catagory

USING '9' 'KDAUF' '' '' '' '' '' 'L' '' '' '' '' 'Sales Order'.

PERFORM ale_field_catagory

USING '10' 'KDPOS' '' '' '' '' '' 'L' '' '' '' '' 'Item'.

PERFORM ale_field_catagory

USING '11' 'PGMNG' '' '' '' '' '' 'L' '' '' '' '' 'Quantity'.

PERFORM ale_field_catagory

USING '12' 'AMEIN' '' '' '' '' '' 'L' '' '' '' '' 'Unit'.

PERFORM ale_field_catagory

USING '13' 'C_MATNR' '' '' '' '' '' 'L' '' '' '' '' 'Config. Material'.

PERFORM ale_field_catagory

USING '14' 'C_MAKTX' '' '' '' '' '' 'L' '' '' '' '' 'Description'.

  • PERFORM ale_field_catagory

  • USING '15' 'AUFNR' '' '' '' '' '' 'L' '' '' '' '' 'Order'.

PERFORM ale_field_catagory

USING '3' 'MATNR' '' '' '' '' '' 'L' '' 'X' '' '' 'Material'.

PERFORM ale_field_catagory

USING '4' 'MAKTX' '' '' '' '' '' 'L' '' '' '' '' 'Description'.

ENDFORM. " alv_declare_key_fields

&----


*& Form ale_field_catagory

&----


  • field display catlog

----


  • -->P_0404 text

  • -->P_0405 text

  • -->P_0406 text

  • -->P_0407 text

  • -->P_0408 text

  • -->P_0409 text

  • -->P_0410 text

  • -->P_0411 text

  • -->P_0412 text

  • -->P_0413 text

  • -->P_0414 text

  • -->P_0415 text

----


FORM ale_field_catagory USING col_pos

fieldname

key

no_zero

do_sum

edit_mask

check

just

no_sum

hotspot

emphasize

icon

htext.

CLEAR it_fcat.

it_fcat-col_pos = col_pos .

it_fcat-fieldname = fieldname.

it_fcat-key = key.

it_fcat-no_zero = no_zero.

it_fcat-do_sum = do_sum.

it_fcat-edit_mask = edit_mask.

it_fcat-checkbox = check.

it_fcat-just = just.

it_fcat-no_sum = no_sum.

it_fcat-hotspot = hotspot.

it_fcat-emphasize = emphasize.

it_fcat-icon = icon.

it_fcat-seltext_l = htext.

APPEND it_fcat.

ENDFORM. " ale_field_catagory

&----


*& Form alv_layout

&----


  • For ALV Layout

----


FORM alv_layout .

lay-zebra = 'X'.

lay-f2code = '&ETA'.

lay-detail_popup = 'X'.

ENDFORM. " alv_layout

&----


*& Form alv_it_sort_subtotal

&----


  • sort & subtotal

----


*

FORM alv_it_sort_subtotal .

PERFORM ale_sort

USING 'MATNR' 'X' 'X'.

ENDFORM. " alv_it_sort_subtotal

&----


*& Form ale_sort

&----


  • text

----


  • -->P_0734 text

  • -->P_0735 text

  • -->P_0736 text

----


FORM ale_sort USING fieldname

subtotal

up.

CLEAR it_sort_subtotal.

it_sort_subtotal-fieldname = fieldname.

it_sort_subtotal-subtot = subtotal.

it_sort_subtotal-up = up.

APPEND it_sort_subtotal.

ENDFORM. " ale_sort

&----


*& Form alv_grid_display

&----


  • ALV Display in grid form

----


FORM alv_grid_display .

v_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

is_layout = lay

it_fieldcat = it_fcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = it_sort_subtotal[]

it_events = it_event[]

TABLES

t_outtab = gt_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. " alv_grid_display

&----


*& Form alv_heading

&----


  • text

----


FORM alv_heading USING typ

key

info.

CLEAR it_heading.

it_heading-typ = typ.

it_heading-key = key.

it_heading-info = info.

APPEND it_heading.

.

ENDFORM. " alv_heading

&----


*& Form get_final

&----


  • Get values in final internal table

----


FORM get_final.

DATA: i_day like dtresr-weekday.

LOOP AT it_afko .

***filling final internal table with gt_allow_sl3 table

gt_final-aufnr = it_afko-aufnr.

READ TABLE it_afpo WITH KEY aufnr = it_afko-aufnr.

READ TABLE it_marc with key matnr = it_afpo-matnr.

READ TABLE it_afvv WITH KEY Aufpl = it_afko-aufpl.

READ TABLE it_vbep WIth KEY vbeln = it_afpo-kdauf posnr = it_afpo-kdpos.

gt_final-matgr = it_marc-matgr.

gt_final-vgw03 = it_afvv-vgw03.

gt_final-fsavd = it_afvv-fsavd.

gt_final-edatu = it_vbep-edatu.

gt_final-item_no = '1'.

gt_final-kdauf = it_afpo-kdauf.

gt_final-kdpos = it_afpo-kdpos.

gt_final-pgmng = it_afpo-pgmng.

gt_final-amein = it_afpo-amein.

gt_final-matnr = it_afpo-matnr.

CALL FUNCTION 'SUPO_MD_MATERIAL_GET_TEXT'

EXPORTING

EV_MATNR = gt_final-matnr

EV_LANGU = 'EN'

IMPORTING

EV_MATTEXT = gt_final-maktx

EXCEPTIONS

NO_TEXT_FOUND = 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.

IF it_afko-maufnr EQ SPACE.

gt_final-c_matnr = it_afko-plnbez.

ELSE.

READ TABLE IT_AFPO WITH KEY AUFNR = IT_AFKO-MAUFNR.

gt_final-c_matnr = it_afpo-matnr.

ENDIF.

CALL FUNCTION 'SUPO_MD_MATERIAL_GET_TEXT'

EXPORTING

EV_MATNR = gt_final-c_matnr

EV_LANGU = 'EN'

IMPORTING

EV_MATTEXT = gt_final-c_maktx

EXCEPTIONS

NO_TEXT_FOUND = 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.

APPEND gt_final.

CLEAR :it_afko, it_afpo.

SORT gt_FINAL ASCENDING BY MATNR.

ENDLOOP.

ENDFORM. "get_final

Regards,

Nik

Former Member
Not what you were looking for? View more on this topic or Ask a question