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

USER-Command at ALV report.

Former Member
0 Likes
23,734

Hi Guys,

I've created one ALV report displaying SALES ORDER created.My requirement is if I click on SALES Document no it should take me into VA03(sales orde display) transaction so that I can see all the data related for that document no. I have used BAPI .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
8,188

If you are not using the OO ALV, then you'll need to do it this way


FORM user_command
        USING p_ucomm LIKE sy-ucomm
              p_selfield TYPE slis_selfield.
*
  IF p_selfield-value NE space.
    CASE p_selfield-tabname.
      WHEN 'IT_OUT'.
        READ TABLE it_out INDEX p_selfield-tabindex
                  INTO out_rec.
      WHEN OTHERS.
        EXIT.
    ENDCASE.
  ELSE.
    EXIT.
  ENDIF.
*
  CHECK sy-subrc = 0.
*
  CASE p_selfield-fieldname.
    WHEN 'QUOTE'   " <== Name of your field in the GRID
      OR 'SALESORD'.
      SET PARAMETER ID 'AUN' FIELD p_selfield-value.
      CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    WHEN OTHERS.
      EXIT.
  ENDCASE.
*
ENDFORM.                    "user_command

If you are not using the OO ALV, then you'll need to do it this way


FORM user_command
        USING p_ucomm LIKE sy-ucomm
              p_selfield TYPE slis_selfield.
*
  IF p_selfield-value NE space.
    CASE p_selfield-tabname.
      WHEN 'IT_OUT'.
        READ TABLE it_out INDEX p_selfield-tabindex
                  INTO out_rec.
      WHEN OTHERS.
        EXIT.
    ENDCASE.
  ELSE.
    EXIT.
  ENDIF.
*
  CHECK sy-subrc = 0.
*
  CASE p_selfield-fieldname.
    WHEN 'QUOTE'   " <== Name of your field in the GRID
      OR 'SALESORD'.
      SET PARAMETER ID 'AUN' FIELD p_selfield-value.
      CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    WHEN OTHERS.
      EXIT.
  ENDCASE.
*
ENDFORM.                    "user_command

5 REPLIES 5
Read only

Former Member
0 Likes
8,188

Use call transaction. You can leverage from the following example for PO's.

METHOD on_double_click.

READ TABLE i_ekkn INTO wa_ekkn WITH KEY po_node = node_key BINARY SEARCH.

IF sy-subrc EQ 0.

SET PARAMETER ID 'BES' FIELD wa_ekkn-ebeln.

CALL TRANSACTION 'ME23N'.

ENDIF.

READ TABLE i_bsis_final INTO wa_bsis WITH KEY po_node = node_key BINARY SEARCH.

IF sy-subrc EQ 0.

SET PARAMETER ID 'BLN' FIELD wa_bsis-belnr.

CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.

ENDIF.

ENDMETHOD. "on_double_click

Read only

Former Member
0 Likes
8,189

If you are not using the OO ALV, then you'll need to do it this way


FORM user_command
        USING p_ucomm LIKE sy-ucomm
              p_selfield TYPE slis_selfield.
*
  IF p_selfield-value NE space.
    CASE p_selfield-tabname.
      WHEN 'IT_OUT'.
        READ TABLE it_out INDEX p_selfield-tabindex
                  INTO out_rec.
      WHEN OTHERS.
        EXIT.
    ENDCASE.
  ELSE.
    EXIT.
  ENDIF.
*
  CHECK sy-subrc = 0.
*
  CASE p_selfield-fieldname.
    WHEN 'QUOTE'   " <== Name of your field in the GRID
      OR 'SALESORD'.
      SET PARAMETER ID 'AUN' FIELD p_selfield-value.
      CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    WHEN OTHERS.
      EXIT.
  ENDCASE.
*
ENDFORM.                    "user_command

Read only

Former Member
0 Likes
8,188

First of all, you'll need to call a Drill Down handling form, on the ALV Function Module call:


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_user_command  = 'f_user_command' " Drill Down Form
      i_callback_pf_status_set = c_pfstat
      i_callback_program = vg_repid
      is_layout = wa_layout
      it_fieldcat = tg_fieldcat[]
      is_variant = wa_variant
      i_save = c_x
    TABLES
      t_outtab                 = tg_output[]
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

And on the form, just input the desired CALL TRANSACTION:


FORM f_user_command USING vl_ucomm LIKE sy-ucomm            "#EC CALLED
                  rs_selfield TYPE slis_selfield.
 
  CASE vl_ucomm.
 
    WHEN '&IC1'.
 
      IF rs_selfield-fieldname = 'FIELD'. "Field to be clicked

        READ TABLE tg_output INTO wa_output INDEX   rs_selfield-tabindex.

        CALL TRANSACTION 'TRANSACTION' AND SKIP FIRST SCREEN.
      ENDIF.
 
    WHEN OTHERS.
 
  ENDCASE.
 
ENDFORM.                    " F_USER_COMMAND

Regards,

Brian Gonsales

Regards,

Brian Gonsales

Read only

0 Likes
8,188

Hi guys,

I have written this code but still it is not taking me into VAO3 Transaction. What else I should write?

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_BUFFER_ACTIVE = 'X'

  • I_BACKGROUND_ID = 'ALV_BACKGROUND'

I_CALLBACK_PROGRAM = L_REPID

  • I_CALLBACK_PF_STATUS_SET = L_STATUS

I_CALLBACK_USER_COMMAND = L_USER_COMMAND

  • I_STRUCTURE_NAME = 'VBUK'

  • IS_LAYOUT = LF_LAYOUT

IT_FIELDCAT = LF_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS = LF_SP_GROUP

  • I_DEFAULT = 'X'

  • I_SAVE = L_SAVE

  • IS_VARIANT = L_VARIANT

  • IT_EVENTS = LF_EVENTS[]

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IT_HEADER .

FORM L_USER_COMMAND USING vl_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE vl_ucomm.

WHEN '&IC1'.

IF rs_selfield-fieldname = 'DOC_NO'

OR rs_selfield-fieldname = 'SO_KUNNR' .

SET PARAMETER ID 'AUN' FIELD rs_selfield-VALUE.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

WHEN OTHERS.

EXIT.

ENDCASE.

ENDFORM.

Read only

0 Likes
8,188

Hi

Do changes like this you can get result

1)

declare like

DATA: c_user_command TYPE slis_formname VALUE 'USER_COMMAND'.

2) in display_alv_report .It may be LIST OR GRID

I_CALLBACK_USER_COMMAND = c_user_command

3)

FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM

I_SELFIELD TYPE SLIS_SELFIELD.

DATA: F_SUBRC LIKE SY-SUBRC,

INPUT_VBELN like GWA_GTY-VBELN.

READ TABLE GTY1 INDEX i_selfield-tabindex INTO INPUT_VBELN.

CASE F_UCOMM.

WHEN '&IC1'.

CASE i_SELFIELD-FIELDNAME.

WHEN 'VBELN'.

CHECK NOT INPUT_VBELN IS INITIAL.

SET PARAMETER ID 'AUN' FIELD INPUT_VBELN.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDCASE.

ENDCASE.

ENDFORM.

here GTY1 is my internal table.

GWA_GTY is work area of GTY1.

4) make sure in your types declaration of GTY1(final table) must contain first field as VBELN.

This code works.

Regards

K.S.L.Neelima