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

Alv overlapped for multiple input

0 Likes
1,516

Hi experts,

I add a additional tab in me22n to display alv but whenever i am giving multiple order in same session its overlapped.Find the attachement below.

SELECT ebeln
          belnr
          menge
          dmbtr FROM ekbe INTO TABLE it_ekbe WHERE ebeln EQ i_ekpo-ebeln.
   SORT it_ekbe DESCENDING BY belnr.
   CLEAR sy-dynnr.
*IF sy-subrc EQ 0.
   LOOP AT it_ekbe INTO wa_ekbe .
     wa_alv-belnr = wa_ekbe-belnr.
     wa_alv-menge = wa_ekbe-menge.
     wa_alv-dmbtr = wa_ekbe-dmbtr.
     lv_u_price = wa_ekbe-dmbtr / wa_ekbe-menge.
     wa_alv-u_price = lv_u_price.
     APPEND wa_alv TO it_alv.
     SORT it_alv DESCENDING BY belnr.

   ENDLOOP.

*IF it_alv IS   NOT INITIAL.
   CLEAR wa_fcat.
   wa_fcat-col_pos = 1.
   wa_fcat-fieldname = 'BELNR'.
   wa_fcat-tabname = 'IT_ALV'.
   wa_fcat-coltext = 'MAT. DOC no.'.
   APPEND wa_fcat TO it_fcat.
   CLEAR wa_fcat.

   wa_fcat-col_pos = 2.
   wa_fcat-fieldname = 'MENGE'.
   wa_fcat-tabname = 'IT_ALV'.
   wa_fcat-coltext = 'QUANTITY'.
   APPEND wa_fcat TO it_fcat.
   CLEAR wa_fcat.

   wa_fcat-col_pos = 3.
   wa_fcat-fieldname = 'DMBTR'.
   wa_fcat-tabname = 'IT_ALV'.
   wa_fcat-coltext = 'AMOUNT'.
   APPEND wa_fcat TO it_fcat.
   CLEAR wa_fcat.

   wa_fcat-col_pos = 4.
   wa_fcat-fieldname = 'U_PRICE'.
   wa_fcat-tabname = 'IT_ALV'.
   wa_fcat-coltext = 'UNIT PRICE'..
   APPEND wa_fcat TO it_fcat.
   CLEAR wa_fcat.
*ENDIF.

   IF it_alv IS NOT INITIAL.
     IF o_cust IS NOT BOUND.

       CREATE OBJECT o_cust
         EXPORTING
           container_name = 'CONTAINER'.
     ENDIF.

     IF o_alv IS INITIAL.
       CREATE OBJECT o_alv
         EXPORTING
           i_parent = o_cust.


       CALL METHOD o_alv->set_table_for_first_display
         CHANGING
           it_outtab       = it_alv
           it_fieldcatalog = it_fcat.

       CALL METHOD o_alv->refresh_table_display.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,487

I don't understand what you mean: "multiple order in same session it's overlapped" ?

Could you explain step by step?

Hi experts,

I add a additional tab in me22n to display alv but whenever i am giving multiple order in same session its overlapped.Find the attachement below.

SELECT ebeln
          belnr
          menge
          dmbtr FROM ekbe INTO TABLE it_ekbe WHERE ebeln EQ i_ekpo-ebeln.
   SORT it_ekbe DESCENDING BY belnr.
   CLEAR sy-dynnr.
*IF sy-subrc EQ 0.
   LOOP AT it_ekbe INTO wa_ekbe .
     wa_alv-belnr = wa_ekbe-belnr.
     wa_alv-menge = wa_ekbe-menge.
     wa_alv-dmbtr = wa_ekbe-dmbtr.
     lv_u_price = wa_ekbe-dmbtr / wa_ekbe-menge.
     wa_alv-u_price = lv_u_price.
     APPEND wa_alv TO it_alv.
     SORT it_alv DESCENDING BY belnr.

   ENDLOOP.

*IF it_alv IS   NOT INITIAL.
   CLEAR wa_fcat.
   wa_fcat-col_pos = 1.
   wa_fcat-fieldname = 'BELNR'.
   wa_fcat-tabname = 'IT_ALV'.
   wa_fcat-coltext = 'MAT. DOC no.'.
   APPEND wa_fcat TO it_fcat.
   CLEAR wa_fcat.

   wa_fcat-col_pos = 2.
   wa_fcat-fieldname = 'MENGE'.
   wa_fcat-tabname = 'IT_ALV'.
   wa_fcat-coltext = 'QUANTITY'.
   APPEND wa_fcat TO it_fcat.
   CLEAR wa_fcat.

   wa_fcat-col_pos = 3.
   wa_fcat-fieldname = 'DMBTR'.
   wa_fcat-tabname = 'IT_ALV'.
   wa_fcat-coltext = 'AMOUNT'.
   APPEND wa_fcat TO it_fcat.
   CLEAR wa_fcat.

   wa_fcat-col_pos = 4.
   wa_fcat-fieldname = 'U_PRICE'.
   wa_fcat-tabname = 'IT_ALV'.
   wa_fcat-coltext = 'UNIT PRICE'..
   APPEND wa_fcat TO it_fcat.
   CLEAR wa_fcat.
*ENDIF.

   IF it_alv IS NOT INITIAL.
     IF o_cust IS NOT BOUND.

       CREATE OBJECT o_cust
         EXPORTING
           container_name = 'CONTAINER'.
     ENDIF.

     IF o_alv IS INITIAL.
       CREATE OBJECT o_alv
         EXPORTING
           i_parent = o_cust.


       CALL METHOD o_alv->set_table_for_first_display
         CHANGING
           it_outtab       = it_alv
           it_fieldcatalog = it_fcat.

       CALL METHOD o_alv->refresh_table_display.

5 REPLIES 5
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,488

I don't understand what you mean: "multiple order in same session it's overlapped" ?

Could you explain step by step?

Read only

0 Likes
1,487

HI rossi,

In ME22N transaction ALV display against PO Its display good for first time but whenever changing the po the new alv gets overlapped with previous one though i used Refresh_table_display.

the written code is given above and the ALV in the attachment.

Read only

0 Likes
1,487

oh okay. It's a very frequent error. It's because you create a new instance of the container/ALV every time, without freeing the previous one, so the first non-freed control is always displayed. Use the FREE method (that's not the FREE statement) to free a control.

Read only

0 Likes
1,487

hi rossy,

I Used that but not working

CALL METHOD o_alv->free
           EXCEPTIONS
             cntl_error        = 1
             cntl_system_error = 2
             OTHERS            = 3.

         CALL METHOD o_cust->free
           EXCEPTIONS
             cntl_error        = 1
             cntl_system_error = 2
             OTHERS            = 3.
*      flag = 'X'.
         FREE o_cust.
         FREE o_alv.

*    LEAVE TO TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
         CLEAR : o_cust , o_alv .
         REFRESH : it_fcat.

Read only

0 Likes
1,487

I can't say anything else than you have to make sure by debug what happens exactly: if a control is created, it must be followed by a free. A control must not be created sucessively twice without having been freed between.