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

Report for Archived data by using exicutable program.

Former Member
0 Likes
414

Hi,

In already existed Zreport data is fetching from table like below.

SELECT belnr bewtp budat lfbnr lfpos FROM ekbe INTO TABLE it_ekbe

                                                             

                                               WHERE bewtp IN ('R' , 'Q') "Only IRs
                                                  AND budat IN s_date.

Like the above in the report fetchnig data from somany tables so mant times.

Now my requirment is the archived consultants archived old data. some table are archived some are not archived.

So i need to fetch the old data also from the archived files. Achived consultants given below details.

zarixmm3------------>zerox table for MM related tables after archived the data.

I searched in google got some code to fetch the data from archived fiels. The below code.

1. I fetched the key  archive key number from the zerox table.

SELECT archivekey  FROM zarixmm3 INTO TABLE it_get

                                   WHERE budat IN s_date

                                     AND werks IN s_werks.



CLEAR : wa_ekbe.

LOOP AT it_get INTO wa_get.

  v_arcdoc = wa_get-archivekey+0(6).

  wa_arcindx1a-archivekey = wa_get-archivekey.

  wa_arcindx1a-v_arcdoc = wa_get-archivekey+0(6).

  CLEAR : wa_get.

  APPEND  wa_arcindx1a TO  it_arcindx1a.

ENDLOOP.



SORT it_arcindx1a BY v_arcdoc.



REFRESH it_get.

CLEAR: v_arcdoc.

DELETE ADJACENT DUPLICATES FROM it_arcindx1a COMPARING v_arcdoc.

2. I passed the key in FMs.

LOOP AT it_arcindx1a INTO wa_arcindx1a.

  v_key = wa_arcindx1a-archivekey+0(6).

  CALL FUNCTION 'ARCHIVE_OPEN_FOR_READ'

    EXPORTING

      archive_document = v_key

*     archive_name     = wa_arcindx1-archivekey

      object           = 'MM_EKKO'

    IMPORTING

      archive_handle   = lv_handle

    EXCEPTIONS

      OTHERS           = 1.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    EXIT.

  ENDIF.



  DO.

    CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'

      EXPORTING

        archive_handle = lv_handle

      EXCEPTIONS

        end_of_file    = 1.          "nur die Ausnahmen, auf die man

    IF sy-subrc <> 0.                "wirklich reagieren will

      EXIT.

    ENDIF.



    CALL FUNCTION 'ARCHIVE_GET_TABLE'

      EXPORTING

        archive_handle        = lv_handle

        record_structure      = 'EKBE'

        all_records_of_object = 'X'

      TABLES

        table                 = git_ekbe_temp

      EXCEPTIONS

        end_of_object         = 0.



    LOOP AT git_ekbe_temp ASSIGNING <ls_ekbe>

                           WHERE bewtp = 'R' OR bewtp = 'Q'

                            AND budat IN s_date.

      MOVE-CORRESPONDING <ls_ekbe> TO wa_ekbe.

      APPEND wa_ekbe TO it_ekbe.

      MOVE-CORRESPONDING <ls_ekbe> TO wa_ekbee.

      APPEND wa_ekbee TO it_ekbee.

      CLEAR wa_ekbe.

      CLEAR wa_ekbee.

    ENDLOOP.

  ENDDO.

  CALL FUNCTION 'ARCHIVE_CLOSE_FILE'

    EXPORTING

      archive_handle = lv_handle.

  CLEAR wa_arcindx1a.

ENDLOOP.

Like the above i diid for all tables wich are used in the Zreport.

Please tell me i am going in right direction or not. The above logic taking time because it is reding entire data in the table.

If new logic is there please provide me to improve performance of the zreport.

Regards,

Maruthi S

1 REPLY 1
Read only

Former Member
0 Likes
357

Hi Friends,

I am waiting for solution aobve.

Regards,

Maruthi. S