cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding ALV.....

Former Member
0 Kudos

Hi,

I hav a column(it is the single column) in alv which comprises of salesorder number delivery number and billing(for example:-0000001040022344 in which upto 10 is sales order number and 400 is delivery number and 22344 is billing)...now the thing is if i double click on sales number it shuld call vA03 and if i do the same on delivery number it shuld go to vl03 and similarly if i click on billing it shuld take me to vf03.....

can anyone help me in this............

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi NEED HELP,

How could You able to do this, share the solution with SCN.

Regards,

Suneel G

Former Member
0 Kudos

FORM user_commands USING syst_ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

CASE:syst_ucomm.

WHEN '&IC1'.

IF selfield-fieldname = 'DEL_NO'. "ur fld name

READ TABLE it_collect INTO wa_collect INDEX selfield-tabindex.

IF sy-subrc EQ 0.

SET PARAMETER ID 'VL' FIELD wa_collect-del_no.

CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.

ENDIF.

ELSEIF selfield-fieldname = 'INV_NO'.

READ TABLE it_collect INTO wa_collect INDEX selfield-tabindex.

IF sy-subrc EQ 0.

SET PARAMETER ID 'VF' FIELD wa_collect-inv_no.

CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDCASE.

In function module set as

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = w_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMANDS'

Former Member
0 Kudos

Hi Need Help,

As you said in your ALV you have only one column, which contains SO + DO + Billing number (together).

From your example 0000001040022344 :

let say User will double clicked on DO ie 400 ok

At Usercommand we will get '0000001040022344' the total value rite ???

Then how will you know User has clicked on 'DO' and as You know system is not an Artifical Intelligence to know User's wish.

The solution is you should have atleast three columns and then follow the replies you got.

Revert me for any queries.

Regards,

Suneel G

Former Member
0 Kudos


REPORT  ZHIERSEQ_ALV.

TYPE-POOLS: slis.                    " ALV Global types
*---------------------------------------------------------------------*
CONSTANTS :
  c_x VALUE 'X',
  c_gt_vbap TYPE slis_tabname VALUE 'GT_VBAP',
  c_gt_vbak TYPE slis_tabname VALUE 'GT_VBAK'.
*---------------------------------------------------------------------*
SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
PARAMETERS p_max(02) TYPE n DEFAULT '10' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(27) v_2 FOR FIELD p_expand. "#EC NEEDED
PARAMETERS p_expand AS CHECKBOX DEFAULT c_x.
SELECTION-SCREEN END OF LINE.
*---------------------------------------------------------------------*
TYPES :
* 1st Table
  BEGIN OF ty_vbak,
    vbeln TYPE vbak-vbeln,             " Sales document
    kunnr TYPE vbak-kunnr,             " Sold-to party
    netwr TYPE vbak-netwr,             " Net Value of the Sales Order
    erdat TYPE vbak-erdat,             " Creation date
    waerk TYPE vbak-waerk,             " SD document currency
    expand TYPE xfeld,
  END OF ty_vbak,

* 2nd Table
  BEGIN OF ty_vbap,
    vbeln TYPE vbap-vbeln,             " Sales document
    posnr TYPE vbap-posnr,             " Sales document
    matnr TYPE vbap-matnr,             " Material number
    arktx TYPE vbap-arktx,             " Material description
    netwr TYPE vbap-netwr,             " Net Value of the Sales Order
    waerk TYPE vbap-waerk,             " SD document currency
  END OF ty_vbap.

*---------------------------------------------------------------------*
DATA :
* 1st Table
  gt_vbak TYPE TABLE OF ty_vbak,
* 2nd Table
  gt_vbap TYPE TABLE OF ty_vbap.

*---------------------------------------------------------------------*
INITIALIZATION.

  v_1 = 'Maximum of records to read'.
  v_2 = 'With ''EXPAND'' field'.

*---------------------------------------------------------------------*
START-OF-SELECTION.

* Read Sales Document: Header Data
  SELECT vbeln kunnr netwr waerk erdat
    FROM vbak
      UP TO p_max ROWS
    INTO CORRESPONDING FIELDS OF TABLE gt_vbak.

  IF gt_vbak[] IS NOT INITIAL.
*   Read Sales Document: Item Data
    SELECT vbeln posnr matnr arktx netwr waerk
      FROM vbap
      INTO CORRESPONDING FIELDS OF TABLE gt_vbap
       FOR ALL ENTRIES IN gt_vbak
     WHERE vbeln = gt_vbak-vbeln.
  ENDIF.

*---------------------------------------------------------------------*
END-OF-SELECTION.

  PERFORM f_display.

*---------------------------------------------------------------------*
*       Form  F_DISPLAY
*---------------------------------------------------------------------*
FORM f_display.

* Macro definition
  DEFINE m_fieldcat.
    ls_fieldcat-tabname = &1.
    ls_fieldcat-fieldname = &2.
    ls_fieldcat-ref_tabname = &3.
    ls_fieldcat-cfieldname = &4.       " Field with currency unit
    append ls_fieldcat to lt_fieldcat.
  END-OF-DEFINITION.

  DEFINE m_sort.
    ls_sort-tabname = &1.
    ls_sort-fieldname = &2.
    ls_sort-up        = c_x.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.

  DATA:
    ls_layout   TYPE slis_layout_alv,
    ls_keyinfo  TYPE slis_keyinfo_alv,
    ls_sort     TYPE slis_sortinfo_alv,
    lt_sort     TYPE slis_t_sortinfo_alv," Sort table
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv." Field catalog

  ls_layout-group_change_edit = c_x.
  ls_layout-colwidth_optimize = c_x.
  ls_layout-zebra             = c_x.
  ls_layout-detail_popup      = c_x.
  ls_layout-get_selinfos      = c_x.
  IF p_expand = c_x.
    ls_layout-expand_fieldname  = 'EXPAND'.
  ENDIF.

* Build field catalog and sort table
  m_fieldcat c_gt_vbak 'VBELN' 'VBAK' ''.
  m_fieldcat c_gt_vbak 'KUNNR' 'VBAK' ''.
  m_fieldcat c_gt_vbak 'NETWR' 'VBAK' 'WAERK'.
  m_fieldcat c_gt_vbak 'WAERK' 'VBAK' ''.
  m_fieldcat c_gt_vbak 'ERDAT' 'VBAK' ''.

  m_fieldcat c_gt_vbap 'POSNR' 'VBAP' ''.
  m_fieldcat c_gt_vbap 'MATNR' 'VBAP' ''.
  m_fieldcat c_gt_vbap 'ARKTX' 'VBAP' ''.
  m_fieldcat c_gt_vbap 'NETWR' 'VBAP' 'WAERK'.
  m_fieldcat c_gt_vbap 'WAERK' 'VBAP' ''.

  m_sort c_gt_vbak 'KUNNR'.
  m_sort c_gt_vbap 'NETWR'.

  ls_keyinfo-header01 = 'VBELN'.
  ls_keyinfo-item01 = 'VBELN'.
  ls_keyinfo-item02 = 'POSNR'.

* Dipslay Hierarchical list
  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    EXPORTING
      i_callback_program      = sy-cprog
      i_callback_user_command = 'USER_COMMAND'
      is_layout               = ls_layout
      it_fieldcat             = lt_fieldcat
      it_sort                 = lt_sort
      i_tabname_header        = c_gt_vbak
      i_tabname_item          = c_gt_vbap
      is_keyinfo              = ls_keyinfo
      i_save                  = 'A'
    TABLES
      t_outtab_header         = gt_vbak
      t_outtab_item           = gt_vbap
    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.                               " F_LIST_DISPLAY
*---------------------------------------------------------------------*
*       Form USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm     TYPE sy-ucomm
                        is_selfield TYPE slis_selfield.     "#EC CALLED

  DATA ls_vbak TYPE ty_vbak.

  CASE i_ucomm.
    WHEN '&IC1'.                       " Pick
      CASE is_selfield-tabname.
        WHEN c_gt_vbap.
        WHEN c_gt_vbak.
          READ TABLE gt_vbak INDEX is_selfield-tabindex INTO ls_vbak.
          IF sy-subrc EQ 0.
*           Sales order number
            SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.
*           Display Sales Order
       CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN. 
    ENDIF.
      ENDCASE.
  ENDCASE.

ENDFORM.                               " USER_COMMAND
Former Member
0 Kudos

Hello,

While preparing the field catalog, for these fields we can set the hot spot and in the user command, we can check the field name and call the corresponding transactions.

the sample code is as follows:

While preparing the field catalog, set the fieldcat-hotspot eq 'X'.

gf_fieldcat-hotspot = 'X'.

gf_fieldcat-emphasize = 'X'.

Create a perform named user_command and pass this Perform name to the ALV Function Module.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = w_repid

  • i_callback_pf_status_set = ' '

i_callback_user_command = 'USER_COMMAND'

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • i_structure_name = '/DCFC/BCXX_AROCR'

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = s_layout

it_fieldcat = gt_fieldcat[]

FORM user_command USING f_ucomm LIKE sy-ucomm

i_selfield TYPE slis_selfield.

READ TABLE itab INDEX i_selfield-tabindex INTO s_itab.

CASE i_selfield-fieldname.

WHEN 'SALES_NUM'.

SET PARAMETER ID 'AUN' FIELD s_itab-VBELN.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

WHEN 'BILLING_NUM'.

.

.

ENDCASE.

ENDFORM.

This way we have to set the parameter ids with the value and call the corresponding transaction.

Now if you click the field in the ALV output, it gets directed to the corresponding document (sales, billing).

Thanks and Regards,

Sowmya Arni

Former Member
0 Kudos

Hi,

As the field where you are clicking is single ..it is not possible to differentiate salesorder number , delivery number and billing.

Better you make three coloumns for salesorder number delivery number and billing.

and then use user command....


*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RUCOMM     text
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                        rs_selfield TYPE slis_selfield.

  CASE r_ucomm.

    WHEN 'SWITCH'.

      PERFORM get_activities.

    WHEN '&IC1'.

      CASE rs_selfield-fieldname.
        WHEN '<BILLING FIELD NAME>'.

          SET PARAMETER ID 'VF' FIELD rs_selfield-value. " VF is parameter id for billing ....

          IF rs_selfield-value IS NOT INITIAL.

            CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.

          ENDIF.

WHEN '<ORDER field name>'.

          SET PARAMETER ID 'AUN' FIELD rs_selfield-value. " AUN is parameter id for sales order ....

          IF rs_selfield-value IS NOT INITIAL.

            CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

          ENDIF.

WHEN '<DELIVERY field name>'.

          SET PARAMETER ID 'VL' FIELD rs_selfield-value. " VL is parameter id for delivery ....

          IF rs_selfield-value IS NOT INITIAL.

            CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.

          ENDIF.

Regards

Debarshi

I355602
Advisor
Advisor
0 Kudos

Hi,

You can give a try using:-


DATA : FLDNAME(25),
       FLDVALUE(25).

CASE sy-ucomm.
  WHEN '&IC1'.
    GET CURSOR FIELD FLDNAME VALUE FLDVALUE.
    IF fldname = '<sales>'.
      "code
    ELSEIF fldname = '<billing>'.
      "code
    ELSEIF fldname = '<document>'.
      "code
    ENDIF.
ENDCASE.
"now when you double click fldname will store fieldname and fldvalue will store the field value

If the above doesnt works, you need to have three different fields, so that it is possible to judge on which column user has double-clicked. So take three different fields instead of one field.

When you double-click on any cell of alv grid, use this code to fetch the data of the line that you currently clicked, its working:-

When you double click on the ALV grid line, you will have sy-ucomm = '&IC1'.

So when you define a i_callback_user_command for the FM reuse_alv_grid_display, and create it as:-


FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
  DATA : ok_code TYPE sy-ucomm.
  ok_code = ucomm.
  CASE ok_code.
    WHEN '&IC1'. "for double click on alv grid line
      " your code
  ENDCASE.
ENDFORM.

As you have used selfield TYPE slis_selfield, the field selfield will hold all the values.

To know on which row you have clicked and to retain that line, use code:-

Suppose you are currently displaying data from internal table itab and corresponding to it you have work area wa.


read table itab into wa index selfield-tabindex. "index value of line you clicked
" now you have the contents of line that you double clicked currently

Now to know the field name that you clicked, use:-


selfield-fieldname " will fetch you the name of field that you clicked

Now using the work-area and the name of field that you clicked, you can easily make out the details of the field i.e., field name and field value and you can code as per your requirement.

Hope this helps you.

Regards,

Tarun

Edited by: Tarun Gambhir on Mar 24, 2009 2:19 PM