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

regarding two alv grid in a program

Former Member
0 Likes
414

i want to create a program. the program will take the sales document date as selection option. then it will show in ALV grid all the sales document number, and net price with in that document date. if i click on any document number, it will show the item detail of that document in a new ALV grid.

can i get any sample code for that?? can anyone please help me??

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
383

hi,

for first off you have to make two field catalog ok..

then write the code for the first alv you want to display (ALV grid all the sales document number, and net price with in that document date.) Then the user command of this ALV you have to call the second one(item detail of that document in a new ALV grid.) ok.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING

      i_callback_program                = sy-repid
*   I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
*    I_CALLBACK_USER_COMMAND           = 'COMMAND'          " this is user command
* 
      is_layout                         = wa_layout
      it_fieldcat                       = it_field

 IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
    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

command which you pass in the user command is a form so you have define it.


*&---------------------------------------------------------------------*
*&      Form  COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->UCOMM      used  to capture the function
*                    code of the user-defined push-buttons
*      -->SELFIELD   text
*----------------------------------------------------------------------*
FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.

*CLEAR WA_FINAL.
*  CASE ucomm.
*
*    WHEN '<usercommand>'.

Perform detail_item.  " here in this perform you can write  the code for second 
*  ENDCASE.

ENDFORM.                    "command

hope this helps

Regards

Ritesh

2 REPLIES 2
Read only

nirajgadre
Active Contributor
0 Likes
383

Hi,

1. Build the first first ALV and populate the docment number and date in this ALV using FM 'REUSE_ALV_GRID_DISPLAY'.

2. write the at user command event on the first ALV and based on the selection of the sales order. populate the item details to the second internal table.

3. Pass this internal table second ALV grid using function module ''REUSE_ALV_GRID_DISPLAY'. call this FM in the USER_COMMAND event of the first ALV.

Read only

Former Member
0 Likes
384

hi,

for first off you have to make two field catalog ok..

then write the code for the first alv you want to display (ALV grid all the sales document number, and net price with in that document date.) Then the user command of this ALV you have to call the second one(item detail of that document in a new ALV grid.) ok.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING

      i_callback_program                = sy-repid
*   I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
*    I_CALLBACK_USER_COMMAND           = 'COMMAND'          " this is user command
* 
      is_layout                         = wa_layout
      it_fieldcat                       = it_field

 IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
    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

command which you pass in the user command is a form so you have define it.


*&---------------------------------------------------------------------*
*&      Form  COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->UCOMM      used  to capture the function
*                    code of the user-defined push-buttons
*      -->SELFIELD   text
*----------------------------------------------------------------------*
FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.

*CLEAR WA_FINAL.
*  CASE ucomm.
*
*    WHEN '<usercommand>'.

Perform detail_item.  " here in this perform you can write  the code for second 
*  ENDCASE.

ENDFORM.                    "command

hope this helps

Regards

Ritesh