Skip to Content
0

unable to write in header after alv refresh

Dec 29, 2016 at 03:24 PM

77

avatar image

Hello,

i have created alv with oops.

i am writing total number of idocs in header.

used split logic of alv for the display.

but i wish to update the count after refresh.

code of refresh logic is as shown in below code.

currently i am getting error (A common cause is that the output table passed to the ALV is not defined globally but locally. Thus, the reference to the table is lost. The ALV no longer has an output table.).

i have declared gt_final globally.

Please suggest.

Thanks,

Darshan

REFRESH: gt_edidc,gt_edids,gt_edid4.

  DATA : lv_var TYPE char255.

  IF NOT gt_final IS INITIAL.

    SELECT docnum status doctyp mesfct sndpor sndprt sndprn

         FROM edidc

         INTO TABLE gt_edidc

         FOR ALL ENTRIES IN gt_final

         WHERE docnum EQ gt_final-docnum.

    IF sy-subrc EQ 0.



    ENDIF.

    IF NOT gt_edidc[] IS INITIAL.

      SELECT docnum statxt stapa1 stapa2 stapa3 stapa4 stamid stamno

                    appl_log

             FROM edids

             INTO TABLE gt_edids

             FOR ALL ENTRIES IN gt_edidc

             WHERE docnum = gt_edidc-docnum AND

                   status EQ gc_51.

      IF sy-subrc EQ 0.



      ENDIF.

    ENDIF.

* Fetch data from EDID4

    IF NOT gt_edids[] IS INITIAL.

      SELECT docnum segnam dtint2 sdata

             FROM edid4

             INTO TABLE gt_edid4

             FOR ALL ENTRIES IN gt_edids

             WHERE docnum = gt_edids-docnum AND

                   segnam IN gr_segnam.

      IF sy-subrc EQ 0.

      ENDIF.

    ENDIF.



    IF NOT gt_edidc[] IS INITIAL.

      DELETE ADJACENT DUPLICATES FROM gt_edids COMPARING docnum.

      SORT: gt_edid4,gt_edidc,gt_edids BY docnum.

      LOOP AT gt_edidc INTO gw_edidc.

        gw_final-status = gw_edidc-status.

        gw_final-doctype = gw_edidc-doctype.

        gw_final-mesfct = gw_edidc-mesfct.

        READ TABLE gt_edid4 INTO gw_edid4 WITH KEY

                                 docnum = gw_edidc-docnum

                                 BINARY SEARCH.

        IF sy-subrc EQ 0.

          IF gw_edid4-segnam EQ 'E1MARAM'.

            lv_var = gw_edid4-sdata+3(18).

            gw_final-matnr  = lv_var.

            gw_final-docnum = gw_edid4-docnum.

          ELSEIF  gw_edid4-segnam EQ 'E1LFA1M'.

            lv_var = gw_edid4-sdata+3(10).

            gw_final-lifnr  = lv_var.

            gw_final-docnum = gw_edid4-docnum.

          ELSEIF gw_edid4-segnam EQ 'E1KNA1M'.

            lv_var = gw_edid4-sdata+3(10).

            gw_final-kunnr  = lv_var.

            gw_final-docnum = gw_edid4-docnum.

          ENDIF.

        ENDIF.



        READ TABLE gt_edids INTO gw_edids WITH KEY

                                 docnum = gw_edidc-docnum

                                 BINARY SEARCH.

        IF sy-subrc EQ 0.

          gw_final-statxt = gw_edids-statxt.

          gw_final-stamid = gw_edids-stamid.

          gw_final-stamno = gw_edids-stamno.

          PERFORM read_text.

          gw_final-appl_log = gv_text.

        ENDIF.



        APPEND gw_final TO gt_final.

        CLEAR: gw_edid4,gw_final,gw_edidc,gw_edids,lv_var,gv_text.

      ENDLOOP.

    ENDIF.

*      PERFORM fill_top_of_page2.

DESCRIBE TABLE gt_final LINES lv_count3.

  lv_count4 = lv_count3.

  CONCATENATE 'No. of Idocs:' lv_count4 INTO lv_var2.

 CREATE OBJECT gv_cust

        EXPORTING

          container_name  = 'CUSTCONT'.



    CREATE OBJECT gv_alv

        EXPORTING

          i_parent  = gv_cust.



    CALL METHOD gv_alv->set_frontend_layout

      EXPORTING

        is_layout = gw_layout.



    CALL METHOD gv_alv->refresh_table_display.
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Tolga POLAT Dec 29, 2016 at 04:52 PM
0

Hi,

First, dont create alv objects every time. check alv created or not.

IF gv_alv IS INITIAL.
* Create container and alv here
ENDIF.

  CALL METHOD gv_alv->set_frontend_layout

      EXPORTING

        is_layout = gw_layout.


CALL METHOD gv_alv->refresh_table_display.

Second, use search. You can find your answer here : https://archive.sap.com/discussions/thread/660907

Kind Regards

Tolga POLAT

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hello,

Thank you for your reply.

My OOPS concepts are not so good..

Could you please suggest where and what i should modify in my code..

Thanks

0

Please improve your reading concepts before "OOPS concepts": Tolga said "dont create alv objects every time. check alv created or not" :

IF gv_alv IS INITIAL.
* Create container and alv here
CREATE OBJECT gv_alv EXPORTING
i_parent = gv_cust.
ENDIF.

0

Hi Tolga,

Please suggest.

0

Hi Darshan,

As Sandra wrote please read carefully. you have to check ALV and Container objects are created or not. If objects already created, dont create again. In your code EVERY PBO events is creating new instance.

Here you can find easy way to write OO ALV : https://wiki.scn.sap.com/wiki/display/Snippets/ABAP+7+Steps+to+create+OOPS+ALV+for+beginners you can change this code for your purpose.

Before writing your code, think carefully. Where you should read data, where you should send data to frontend etc. Search and study for PBO and PAI logic of screen.

Kind Regards

1