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

Interactive ALV

Former Member
0 Likes
1,305

Dear friends,

I have an alv report. In that if i click on the document number it has to go to VA03 and ME23N.

IF that document is sales, it has to go to VA03.

IF that document is Purchase, it has to go to ME23N

Please help me in this

Thanks in advance

Regards,

Ajay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,253

Hi,

get the parameter id of the field from the attributes screen of that field.

SET PARAMETER ID '<parameter id of that field>' FIELD <selection screen field>.

or to get the parameter id of the field go to the screen by executing the transaction and goto the F1 help of that field and in the F1 help press the technical information button.one window will appear to you.in that u can see the parameter id of that field.

check the sample code

SET PARAMETER ID : 'BLN' FIELD lv_belnr,

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

Sample program

code

report zrich_0001.

Global ALV Data Declarations

type-pools: slis.

Internal Tables

data: begin of itab occurs 0,

matnr type mara-matnr,

maktx type makt-maktx,

end of itab.

start-of-selection.

perform get_data.

perform call_alv.

*********************************************************************

Form GET_DATA

*********************************************************************

form get_data.

select maramatnr maktmaktx

into corresponding fields of table itab

from mara

inner join makt

on maramatnr = maktmatnr

up to 20 rows.

endform.

************************************************************************

CALL_ALV

************************************************************************

form call_alv.

data: ifc type slis_t_fieldcat_alv.

data: xfc type slis_fieldcat_alv.

data: repid type sy-repid.

repid = sy-repid.

clear xfc. refresh ifc.

clear xfc.

xfc-reptext_ddic = 'Material Number'.

xfc-fieldname = 'MATNR'.

xfc-tabname = 'ITAB'.

xfc-outputlen = '18'.

append xfc to ifc.

clear xfc.

xfc-reptext_ddic = 'Material Description'.

xfc-fieldname = 'MAKTX'.

xfc-tabname = 'ITAB'.

xfc-outputlen = '40'.

append xfc to ifc.

Call ABAP List Viewer (ALV)

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = repid

i_callback_user_command = 'HANDLE_USER_COMMAND'

it_fieldcat = ifc

tables

t_outtab = itab.

endform.

***********************************************************************

FORM handle_User_Command *

***********************************************************************

form handle_user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when '&IC1'.

case rs_selfield-FIELDNAME.

when 'MATNR'.

set parameter id 'MAT' field rs_selfield-value.

call transaction 'MD04' and skip first screen.

endcase.

endcase.

endform.

[/code]

Regards,

Raj.

8 REPLIES 8
Read only

Former Member
0 Likes
1,253

I need help for Interactive ALV. I can check for the document is either sales or purchase.

Please help me in this

Thanks

Ajay

Read only

Former Member
0 Likes
1,254

Hi,

get the parameter id of the field from the attributes screen of that field.

SET PARAMETER ID '<parameter id of that field>' FIELD <selection screen field>.

or to get the parameter id of the field go to the screen by executing the transaction and goto the F1 help of that field and in the F1 help press the technical information button.one window will appear to you.in that u can see the parameter id of that field.

check the sample code

SET PARAMETER ID : 'BLN' FIELD lv_belnr,

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

Sample program

code

report zrich_0001.

Global ALV Data Declarations

type-pools: slis.

Internal Tables

data: begin of itab occurs 0,

matnr type mara-matnr,

maktx type makt-maktx,

end of itab.

start-of-selection.

perform get_data.

perform call_alv.

*********************************************************************

Form GET_DATA

*********************************************************************

form get_data.

select maramatnr maktmaktx

into corresponding fields of table itab

from mara

inner join makt

on maramatnr = maktmatnr

up to 20 rows.

endform.

************************************************************************

CALL_ALV

************************************************************************

form call_alv.

data: ifc type slis_t_fieldcat_alv.

data: xfc type slis_fieldcat_alv.

data: repid type sy-repid.

repid = sy-repid.

clear xfc. refresh ifc.

clear xfc.

xfc-reptext_ddic = 'Material Number'.

xfc-fieldname = 'MATNR'.

xfc-tabname = 'ITAB'.

xfc-outputlen = '18'.

append xfc to ifc.

clear xfc.

xfc-reptext_ddic = 'Material Description'.

xfc-fieldname = 'MAKTX'.

xfc-tabname = 'ITAB'.

xfc-outputlen = '40'.

append xfc to ifc.

Call ABAP List Viewer (ALV)

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = repid

i_callback_user_command = 'HANDLE_USER_COMMAND'

it_fieldcat = ifc

tables

t_outtab = itab.

endform.

***********************************************************************

FORM handle_User_Command *

***********************************************************************

form handle_user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when '&IC1'.

case rs_selfield-FIELDNAME.

when 'MATNR'.

set parameter id 'MAT' field rs_selfield-value.

call transaction 'MD04' and skip first screen.

endcase.

endcase.

endform.

[/code]

Regards,

Raj.

Read only

Former Member
0 Likes
1,253

Hi,

create two menu options like sales ,purchase using set-pf status .then go to se41 create options.

here use get cursor command to hold value whtever you preesed.

after that call transaction vao3 when sales.like that.

TRy like that.

Read only

saranwin
Contributor
0 Likes
1,253

Hi,

For ur requirtment use ALV List Function Module and try the same. Validate the data in Interactie List to get the Details of Purchase or Sales data and Call the Transaction Me23n or VA03.

Regards,

Saran

Read only

Former Member
0 Likes
1,253

While defining the field catalog enable HOTSPOT. In in routine USER_COMMAND, check the field selected and accordingly call the required transaction. Below code can give you a simple idea:

      CASE I_SELFIELD-SEL_TAB_FIELD.
        WHEN 'I_ARSEG-BELNR'.
          CHECK NOT ST_ARSEG-BELNR IS INITIAL.
          SET PARAMETER ID 'RBN' FIELD ST_ARSEG-BELNR.
          SET PARAMETER ID 'GJR' FIELD ST_ARSEG-GJAHR.
          CALL TRANSACTION TCODE_MIR4 AND SKIP FIRST SCREEN.

        WHEN 'I_ARSEG-LIFNR'.
          SET PARAMETER ID 'LIF' FIELD ST_ARSEG-LIFNR.
          SET PARAMETER ID 'KDY' FIELD '/110'.
          CALL TRANSACTION 'MK03' AND SKIP FIRST SCREEN.

        WHEN 'I_ARSEG-EBELN'.
          CALL FUNCTION 'MR_PO_DISPLAY'
            EXPORTING
              I_EBELN = ST_ARSEG-EBELN.

        WHEN 'I_ARSEG-BELNR_FI'.
          CHECK NOT ST_ARSEG-BELNR IS INITIAL.
          READ TABLE I_ARSEG INTO ST_ARSEG
               WITH KEY BELNR = ST_ARSEG-BELNR
                        GJAHR = ST_ARSEG-GJAHR.
          PERFORM SHOW_FI_DOC
                USING ST_ARSEG-BUKRS
                      ST_ARSEG-BELNR_FI
                      ST_ARSEG-GJAHR.

      ENDCASE.

Read only

Former Member
0 Likes
1,253

Hi

write code like this in your interactive alv report.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_top_of_page = 'TOP-OF-PAGE2'

i_callback_pf_status_set = 'SET_PF_STATUS'

is_layout = wa_layout

it_fieldcat = it_fieldcat

TABLES

t_outtab = it_ekpo

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.

&----


*& form set_pf_status

&----


FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'MYMENU'.

"Copy of 'STANDARD' pf_status from fgroup SALV

ENDFORM. "set_pf_status

&----


*& Form AT_user_command

&----


FORM at_user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN 'SAI'.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

WHEN 'DISP'.

call transaction 'ME23N' and skip first screen.

ENDCASE.

ENDFORM. "AT_user_command

in mymenu status you put these two buttons(sai,disp) as push buttons.

Read only

Former Member
0 Likes
1,253

Hi,

check out this code....copy-paste it......then.......

type-pools : slis.

data : it type STANDARD TABLE OF vbak.

data : it_event TYPE slis_t_event ,

wa_event LIKE LINE OF it_event .

select * from vbak into table it.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = it_event

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

LOOP AT it_event INTO wa_event .

IF wa_event-name = 'USER_COMMAND' .

wa_event-form = 'TRANCALL' .

MODIFY it_event FROM wa_event INDEX sy-tabix .

ENDIF.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_STRUCTURE_NAME = 'vbak'

IT_EVENTS = IT_EVENT

TABLES

T_OUTTAB = it.

FORM TRANCALL USING fp_ucom TYPE sy-ucomm

fp_selfield TYPE slis_selfield .

IF fp_ucom = '&IC1' .

//* call transaction : according to the contents of fp_selfield *//

/// * if needed set memory id//

///* call transcation <TCODE> 'SKIP INITIAL SCREEN'.

ENDIF.

ENDFORM.

.............. By going into debug mode you can look -out the content of the structure : fp_selfield . It contains all the information You need !!!

Reward points if helpful...........

Read only

Former Member
0 Likes
1,253

Hi,

Please refer the link below:

http://www.sapdev.co.uk/reporting/alv/alvgrid_enhanced.htm

Thanks,

Sriram POnna.