Application Development 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: 

Problem in Interactive ALV

Former Member
0 Kudos

hi,

    i am new to abap.. i have a requirement input is PO number and based on input to display PO number, ASN number,GRN number and invoice details usin ALV report.i have done the code... but i am not getting the output... problem is when i double click on PO field it will not go to second page to display GRN number.. whats is the problem... plz help me...

TYPE-POOLS: SLIS.

TYPES : BEGIN OF EKES,

         EBELN TYPE EKES-EBELN,

         VBELN TYPE EKES-VBELN,

         END OF EKES.


DATA : IT_EKES TYPE TABLE OF EKES,

       WA_EKES TYPE EKES.


TYPES : BEGIN OF MSEG,

        EBELN TYPE MSEG-EBELN,

        EBELP TYPE MSEG-EBELP,

        WEMPF TYPE MSEG-WEMPF,

        END OF MSEG.


DATA : IT_MSEG TYPE TABLE OF MSEG,

       WA_MSEG TYPE MSEG.


TYPES : BEGIN OF RSEG,

        EBELN TYPE RSEG-EBELN,

        BELNR TYPE RSEG-BELNR,

        MENGE TYPE RSEG-MENGE,

        END OF RSEG.


DATA : IT_RSEG TYPE TABLE OF RSEG,

       WA_RSEG TYPE RSEG.


DATA: REPID TYPE SY-REPID,

      IT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV,

      WA_FIELDCAT  TYPE SLIS_FIELDCAT_ALV.


SELECT-OPTIONS EBELN FOR WA_EKES-EBELN.


START-OF-SELECTION.

SELECT EBELN VBELN FROM EKES INTO TABLE IT_EKES WHERE EBELN IN EBELN.


WA_FIELDCAT-TABNAME = 'IT_EKES'.

  WA_FIELDCAT-FIELDNAME = 'EBELN'.

  WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.


  WA_FIELDCAT-TABNAME = 'IT_EKES'.

  WA_FIELDCAT-FIELDNAME = 'VBELN'.

  WA_FIELDCAT-SELTEXT_M = 'ASN NO.'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.


LOOP AT IT_EKES INTO WA_EKES.

  WRITE : / WA_EKES-EBELN,

            WA_EKES-VBELN.

HIDE WA_EKES-EBELN.

ENDLOOP.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      IT_FIELDCAT   = IT_FIELDCAT

    TABLES

      T_OUTTAB      = IT_EKES[]

    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.


AT LINE-SELECTION .

  IF SY-LSIND  = 1.


SELECT EBELN EBELP WEMPF FROM MSEG INTO TABLE IT_MSEG WHERE EBELN = WA_EKES-EBELN.


  WA_FIELDCAT-TABNAME = 'IT_MSEG'.

  WA_FIELDCAT-FIELDNAME = 'EBELN'.

  WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.


  WA_FIELDCAT-TABNAME = 'IT_EBELP'.

  WA_FIELDCAT-FIELDNAME = 'EBELP'.

  WA_FIELDCAT-SELTEXT_M = 'ITEM NO.'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.



  WA_FIELDCAT-TABNAME = 'IT_MSEG'.

  WA_FIELDCAT-FIELDNAME = 'WEMPF'.

  WA_FIELDCAT-SELTEXT_M = 'GRN NO.'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.



IF SY-SUBRC EQ 0.

LOOP AT IT_MSEG INTO WA_MSEG.

        WRITE😕 WA_MSEG-EBELN, WA_MSEG-EBELP, WA_MSEG-WEMPF.

        HIDE WA_MSEG-EBELN.

      ENDLOOP.

ENDIF.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      IT_FIELDCAT   = IT_FIELDCAT

    TABLES

      T_OUTTAB      = IT_MSEG[]

    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.



ELSEIF SY-LSIND  = 2.

    SELECT EBELN BELNR MENGE FROM RSEG INTO TABLE IT_RSEG WHERE EBELN = WA_MSEG-EBELN.


  WA_FIELDCAT-TABNAME = 'IT_RSEG'.

  WA_FIELDCAT-FIELDNAME = 'EBELN'.

  WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.



  WA_FIELDCAT-TABNAME = 'IT_RSEG'.

  WA_FIELDCAT-FIELDNAME = 'BELNR'.

  WA_FIELDCAT-SELTEXT_M = 'INVOICE DETAILS .'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.



    WA_FIELDCAT-TABNAME = 'IT_RSEG'.

  WA_FIELDCAT-FIELDNAME = 'MENGE'.

  WA_FIELDCAT-SELTEXT_M = 'QUANTITY.'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  CLEAR WA_FIELDCAT.



      IF SY-SUBRC = 0.


      LOOP AT IT_RSEG INTO WA_RSEG.

        WRITE😕 WA_RSEG-EBELN, WA_RSEG-BELNR, WA_RSEG-MENGE.

        HIDE WA_RSEG-EBELN.

      ENDLOOP.

    ENDIF.



CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      IT_FIELDCAT   = IT_FIELDCAT

    TABLES

      T_OUTTAB      = IT_RSEG[]

    EXCEPTIONS

      PROGRAM_ERROR = 1

      OTHERS        = 2.



ENDIF.

Moderator Message: <<subject altered>> Use proper subject line while posting

Message was edited by: Kesavadas Thekkillath

10 REPLIES 10

Former Member
0 Kudos

Hi Navya,

The code seems correct. Did you a give a valid PO number which has GRN details...? You had the second list logic inside a sy-subrc check. So, I guess if you dont have a valid PO then that wont take you to the second list.

Hope this helps you.

Regards,

Sindhu Pulluru.

0 Kudos

i checked valid PO numb... if i double click on valid number also it will not display second list...

SharathSYM
Contributor
0 Kudos

Hi Navya,

why are you using loop...write...endloop statements, if you are using ALV display..

Please refer to the code attached for your reference & re-design your code according to it.

Get back to me if you face any problems....

Regards,

Sharath

Former Member
0 Kudos

Hi Navya,

Your coding is right. But the problem is you are getting output as list( With write statement)  as well as grid display.

So once you run ur report first u r getting grid display. if you press back button then you will get the list display. If you click there , you will get the GRN details.

Regards,

Ramya R

0 Kudos

Ok... i removed the write statement... now i am getting the grid display but when i double click on first list it will not go second list... why?

0 Kudos

Hi Navya,

I guess this might be because you are using the same tablename for fieldcatalog...For second list, when you append your fields, it will be added to the fields for the first list...I think you got me...I am not sure if this is the problem...but just a guess...Please check by giving different fieldcatalog table name to each list.

Hope this helps you.

Regards,

Sindhu Pulluru.

0 Kudos

Hi Navya ,

The code what you have written is List. So you give write statement . remove Grid.

Because to get the records by double clicking , there is different procedure in ALV Grid display.

The code what u have written is for LIST. so please remove Grid and check , You will get the output.

Regards,

Ramya R

0 Kudos

Hi Navya,

Initially you are displaying the report in grid display.So,if you want to trigger the second list you have to use events in alv.For triggering secondary list use USER_COMMAND event in grid display and write subroutine to perform the logic.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

  EXPORTING

   I_CALLBACK_PROGRAM                = sy-cprog

   I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'

   IT_EVENTS                         = T_EVENT

         .

form USER_COMMAND using a like sy-ucomm b type slis_selfield.

   IF b-fieldname = 'EBELN'.

     V3 = B-VALUE.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

   EXPORTING

     INPUT         = V3

  IMPORTING

    OUTPUT        = V3.

   select   EBELN

           EBELP

           MENGE

           MATNR

           BELNR

           Budat

           from ekbe

           into table t_ekbe

           where ebeln = V3.

   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

   I_CALLBACK_PROGRAM                = SY-CPROG

     IT_FIELDCAT                       = T_FCAT .

  endform.

yogendra_bhaskar
Contributor
0 Kudos

Hi Navya ,

Your code is correct and will work fine as you required.

Just check , are you getting any data in your internal table depending upon your input,

or you may add code after select statement :

if it_EKES[] is initial.

    message 'No record found' type 'S'.

    leave to current transaction.

endif.

regards ,

Yogendra Bhaskar

Former Member
0 Kudos

Hi Navya,

To work with Interactive ALV, You will have to declare an itab with slis_t_event as data type.

Now this itab will have 2 fields one as NAME and another as FORM. Fill this itab using work area by giving event name as 'USER_COMMAND' to NAME and form name  to FORM.

Now assign this itab to the exporting parameter IT_EVENTS in the FM 'reuse_alv_grid_display' and call the relevant subroutine at the end of the program.

Call the form name  like this :

FORM HANDLE_USER_COMMAND USING R_COMM TYPE SY-UCOMM

                                                                              RS_SELFIELD TYPE SLIS_SELFIELD.

Write your relevant coding in the subroutine.

Rgds..