Skip to Content

LOOP AND APPEND PROBLEM.

Hi Folks,

I had highlighted a part of the code down here.

If I use APPEND in that loop it is running indefinitely.

If I use modify it is going to dump.

Due to that I am not getting the BELNR in the where clause of the subsequent loops and thus not able to select the data for some fields.

Kindly help me with this.

REPORT ZMIG

TABLES:MKPF,

MSEG,

EKPO,

RBKP,

RSEG,

LFA1.

TYPE-POOLS:SLIS.

TYPES:BEGIN OF X_MKPF,

MBLNR LIKE MKPF-MBLNR,

MJAHR LIKE MKPF-MJAHR,

BUDAT LIKE MKPF-BUDAT,

XBLNR LIKE MKPF-XBLNR,

END OF X_MKPF.

TYPES:BEGIN OF X_FINAL,

SL_NO LIKE SY-TABIX,

MBLNR LIKE MKPF-MBLNR, "MIGO No.

MJAHR LIKE MKPF-MJAHR,

BUDAT LIKE MKPF-BUDAT, "MIGO DATE

XBLNR LIKE MKPF-XBLNR,

ZEILE LIKE MSEG-ZEILE,

BUKRS LIKE MSEG-BUKRS,

LGORT LIKE MSEG-LGORT,

BWART LIKE MSEG-BWART,

MATNR LIKE MSEG-MATNR,

LIFNR LIKE MSEG-LIFNR,

BWTAR LIKE MSEG-BWTAR,

MENGE LIKE MSEG-MENGE, "Quantity in MSEG

EBELN LIKE MSEG-EBELN,

EBELP LIKE MSEG-EBELP,

WEBRE LIKE EKPO-WEBRE,

AEDAT LIKE EKKO-AEDAT, "PO Date

MENGE1 LIKE EKPO-MENGE, "PO Quantity in EKPO

BELNR LIKE RSEG-BELNR,

GJAHR LIKE RSEG-GJAHR,

MENGE2 LIKE RSEG-MENGE, "Quantity in RSEG

LFBNR LIKE RSEG-LFBNR,

LFGJA LIKE RSEG-LFGJA,

LFPOS LIKE RSEG-LFPOS,

BUDAT1 LIKE RBKP-BUDAT, "MIRO Date

END OF X_FINAL.

*INTERNAL TABLE FOR RBKP AND RSEG.

TYPES:BEGIN OF X_TEMP,

BELNR LIKE RBKP-BELNR,

GJAHR LIKE RBKP-GJAHR,

EBELN LIKE RSEG-EBELN,

EBELP LIKE RSEG-EBELP,

MATNR LIKE RSEG-MATNR,

BUKRS LIKE RSEG-BUKRS,

MENGE LIKE RSEG-MENGE,

XBLNR LIKE RSEG-XBLNR,

LFGJA LIKE RSEG-LFGJA,

LFPOS LIKE RSEG-LFPOS,

LIFNR LIKE RSEG-LIFNR,

END OF X_TEMP.

DATA:ITMKPF TYPE x_MKPF OCCURS 0 WITH HEADER LINE.

DATA:ITTEMP TYPE X_TEMP OCCURS 0 WITH HEADER LINE.

DATA:ITFINAL TYPE X_FINAL OCCURS 0 WITH HEADER LINE.

*Declarations for ALV

DATA:itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA:itrepid TYPE sy-repid.

itrepid = sy-repid.

DATA:itevent TYPE slis_t_event.

DATA:itlistheader TYPE slis_t_listheader.

DATA:walistheader LIKE LINE OF itlistheader.

DATA:itlayout TYPE slis_layout_alv.

DATA:top TYPE slis_formname.

DATA:itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.

DATA :itsort1 TYPE slis_sortinfo_alv.

DATA:itprintparams TYPE slis_print_alv.

DATA:itvariant TYPE disvariant.

DATA :i(2), "month

y TYPE int4, "year

c(4).

DATA:STRING1(75),STRING2(75),

TITLE1(75),

DATE1(10),

DATE2(10).

SELECTION-SCREEN BEGIN OF SCREEN 100 TITLE MIGO.

PARAMETERS: R1 RADIOBUTTON GROUP G1 USER-COMMAND KK1 DEFAULT 'X',

R2 RADIOBUTTON GROUP G1.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_BUKRS1 FOR MSEG-BUKRS MODIF ID K1,

S_PLANT FOR MSEG-WERKS MODIF ID K1,

S_BUDAT FOR MKPF-BUDAT OBLIGATORY MODIF ID K1,

S_LIFNR1 FOR LFA1-LIFNR MODIF ID K1.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

SELECT-OPTIONS:S_EBELN FOR MSEG-EBELN MODIF ID K2,

S_LIFNR2 FOR LFA1-LIFNR MODIF ID K2,

S_BUKRS2 FOR MSEG-BUKRS MODIF ID K2,

S_WERKS FOR MSEG-WERKS MODIF ID K2.

SELECTION-SCREEN END OF BLOCK B2.

SELECTION-SCREEN END OF SCREEN 100.

CALL SELECTION-SCREEN 100.

AT SELECTION-SCREEN OUTPUT.

IF R1 = 'X'.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'K1'.

SCREEN-ACTIVE = '0'.

SCREEN-INPUT = '0'.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDIF.

IF R2 = 'X'.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'K2'.

SCREEN-ACTIVE = '0'.

SCREEN-INPUT = '0'.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDIF.

start-of-selection.

PERFORM GETDATA.

PERFORM ALV.

*end-of-selection.

&----


*& Form GETDATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form GETDATA .

SELECT MBLNR

MJAHR

BUDAT

XBLNR

FROM MKPF INTO CORRESPONDING FIELDS OF TABLE ITMKPF

WHERE BUDAT IN S_BUDAT.

IF sy-subrc NE 0.

MESSAGE 'No Values exist for the Selection.' TYPE 'S'.

ENDIF.

LOOP AT ITMKPF.

MOVE-CORRESPONDING ITMKPF TO ITFINAL.

SELECT MBLNR

MJAHR

ZEILE

BWART

MATNR

WERKS

LGORT

LIFNR

BWTAR

MENGE

EBELN

EBELP

BUKRS

FROM MSEG INTO CORRESPONDING FIELDS OF ITFINAL

WHERE MBLNR = ITMKPF-MBLNR

AND MJAHR = ITMKPF-MJAHR.

*TO GET THE PO QUANTITY AND GR BASED INDICATOR

*SELECT SINGLE MENGE

  • WEBRE

  • FROM EKPO INTO CORRESPONDING FIELDS OF ITFINAL

  • WHERE EBELN = ITFINAL-EBELN

  • AND EBELP = ITFINAL-EBELP.

SELECT SINGLE MENGE

WEBRE

FROM EKPO INTO (ITFINAL-MENGE1,ITFINAL-WEBRE)

WHERE EBELN = ITFINAL-EBELN

AND EBELP = ITFINAL-EBELP.

*TO GET THE PO DATE.

SELECT SINGLE AEDAT

FROM EKKO INTO ITFINAL-AEDAT

WHERE EBELN = ITFINAL-EBELN.

APPEND ITFINAL.

ENDSELECT.

CLEAR ITFINAL.

CLEAR ITMKPF.

ENDLOOP.

LOOP AT ITFINAL.

IF ITFINAL-WEBRE NE 'X'.

DELETE ITFINAL.

ENDIF.

ENDLOOP.

***********12*******

LOOP AT ITFINAL.

SELECT BELNR

GJAHR

FROM RBKP INTO CORRESPONDING FIELDS OF ITTEMP

WHERE XBLNR = ITFINAL-XBLNR

AND LIFNR = ITFINAL-LIFNR

AND BUKRS = ITFINAL-BUKRS. "26

APPEND ITTEMP.

ENDSELECT.

CLEAR ITTEMP.

CLEAR ITFINAL.

ENDLOOP.

LOOP AT ITTEMP.

SELECT EBELN

EBELP

MATNR

BUKRS

MENGE

XBLNR

LFBNR

LFGJA

LFPOS

LIFNR

FROM RSEG INTO CORRESPONDING FIELDS OF ITTEMP

WHERE BELNR = ITTEMP-BELNR

AND GJAHR = ITTEMP-GJAHR.

MODIFY ITTEMP.

ENDSELECT.

ENDLOOP.

<b>LOOP AT ITFINAL.

MOVE-CORRESPONDING ITTEMP TO ITFINAL.

CLEAR ITTEMP.

CLEAR ITFINAL.

ENDLOOP.</b>

************12****************

**TO GET THE MIRO DATE

LOOP AT ITFINAL.

SELECT SINGLE BUDAT

FROM RBKP INTO (ITFINAL-BUDAT1)

WHERE BELNR = ITFINAL-BELNR "XBLNR

AND GJAHR = ITFINAL-GJAHR.

  • AND LIFNR = ITFINAL-LIFNR "26

  • AND BUKRS = ITFINAL-BUKRS. "26

*TO GET THE MIRO QUANTITY

SELECT SINGLE MENGE

FROM RSEG INTO (ITFINAL-MENGE2)

WHERE BELNR = ITFINAL-BELNR

AND GJAHR = ITFINAL-GJAHR.

MODIFY ITFINAL.

ENDLOOP.

endform. " GETDATA

&----


*& Form ALV

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form ALV .

LOOP AT ITFINAL.

ITFINAL-SL_NO = SY-TABIX.

MODIFY ITFINAL.

ENDLOOP.

itlayout-zebra = 'X'.

itlayout-colwidth_optimize = 'X'.

itlayout-no_subtotals = ' '.

IF itfinal[] IS INITIAL.

MESSAGE 'No Values exist for the Selection.' TYPE 'S'.

STOP.

ENDIF.

DEFINE m_fieldcat.

itfieldcat-fieldname = &1.

itfieldcat-col_pos = &2.

itfieldcat-seltext_l = &3.

itfieldcat-do_sum = &4.

itfieldcat-outputlen = &5.

append itfieldcat to itfieldcat.

clear itfieldcat.

END-OF-DEFINITION.

*m_fieldcat 'SL_NO' '' 'SL. NO' '' 03.

*m_fieldcat 'MBLNR' '' 'Materil Doc.No' '' 10.

*m_fieldcat 'MJAHR' '' 'Material Doc.Yr.' '' 04.

*m_fieldcat 'BUDAT' '' 'POSTING DATE' '' 08.

*m_fieldcat 'ZEILE' '' 'Item in Mat.Doc.' '' 04.

**m_fieldcat 'WERKS' '' 'Plant' '' 04 .

*m_fieldcat 'LGORT' '' 'Storage Location' '' 04.

*m_fieldcat 'BWART' '' 'Movement Type' '' 03.

*m_fieldcat 'MATNR' '' 'Material No.' '' 18.

*m_fieldcat 'BWTAR' '' 'Valutaion Type' '' 10.

*m_fieldcat 'LIFNR' '' 'Vendor' '' 10.

*m_fieldcat 'MENGE' '' 'Quantity' '' 13.

*m_fieldcat 'EBELN' '' 'PO.No' '' 10.

*m_fieldcat 'EBELP' '' 'Item No.of PO Doc' '' 05.

*m_fieldcat 'MENGE1' '' 'PO Quantity' '' 13.

*m_fieldcat 'WEBRE' '' 'GR.Indicator' '' 01.

*m_fieldcat 'XBLNR' '' 'Ref.Doc No.' '' 16.

*m_fieldcat 'BELNR' '' 'Accounting Doc.No.' '' 10.

*m_fieldcat 'GJAHR' '' 'Fiscal Yr.' '' 04.

*m_fieldcat 'MENGE2' '' 'MIRO Quantity' '' 13.

m_fieldcat 'SL_NO' '' 'SL. NO' '' 03.

m_fieldcat 'MBLNR' '' 'MIGO.No' '' 10.

m_fieldcat 'BUDAT' '' 'MIGO DATE' '' 08.

m_fieldcat 'MJAHR' '' 'Material Doc.Yr.' '' 04.

m_fieldcat 'XBLNR' '' 'Ref.Doc No.' '' 16.

m_fieldcat 'MENGE' '' 'MIGO Quantity' '' 13.

*****

m_fieldcat 'EBELN' '' 'PO.No' '' 10.

m_fieldcat 'AEDAT' '' 'PO.Date' '' 08.

m_fieldcat 'MENGE1' '' 'PO Quantity' '' 13.

*****

m_fieldcat 'BELNR' '' 'MIRO No.' '' 10.

m_fieldcat 'BUDAT1' '' 'MIRO DATE' '' 08.

m_fieldcat 'MENGE2' '' 'MIRO Quantity' '' 13.

m_fieldcat 'LIFNR' '' 'Vendor' '' 10.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

I_CALLBACK_TOP_OF_PAGE = 'TOP'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = ITLAYOUT

IT_FIELDCAT = ITFIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = ITEVENT[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = ITFINAL

  • 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. " ALV

FORM TOP.

WRITE: S_BUDAT-LOW TO DATE1,

S_BUDAT-HIGH TO DATE2.

IF R1 = 'X'.

string1 = 'NON GR BASED DOCUMENTS FROM :'.

CONCATENATE string1 date1 'to' date2 INTO title1 SEPARATED BY space.

walistheader-typ = 'H'.

walistheader-info = title1.

APPEND walistheader TO itlistheader.

ELSE.

string2 = 'GR BASED DOCUMENTS FROM :'.

CONCATENATE string2 date1 'to' date2 INTO title1 SEPARATED BY space.

walistheader-typ = 'H'.

walistheader-info = title1.

APPEND walistheader TO itlistheader.

ENDIF.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = ITEVENT

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 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.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = ITLISTHEADER

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

CLEAR ITLISTHEADER.

ENDFORM.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 07:00 AM

    LOOP AT ITFINAL.

    MOVE-CORRESPONDING ITTEMP TO ITFINAL.

    CLEAR ITTEMP.

    CLEAR ITFINAL.

    ENDLOOP.

    chk two strture or same.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 07:01 AM

    LOOP AT ITFINAL.

    MOVE-CORRESPONDING<b> ITFINAL TO ITTEMP .

    append itemp.</b>

    CLEAR ITTEMP.

    CLEAR ITFINAL.

    ENDLOOP.

    i think the above is what u want to do..

    regards,

    aparna

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 07:02 AM

    Hi Kiran

    why r u writing like this

    LOOP AT ITTEMP.

    SELECT EBELN

    EBELP

    MATNR

    BUKRS

    MENGE

    XBLNR

    LFBNR

    LFGJA

    LFPOS

    LIFNR

    FROM RSEG INTO CORRESPONDING FIELDS OF ITTEMP

    WHERE BELNR = ITTEMP-BELNR

    AND GJAHR = ITTEMP-GJAHR.

    MODIFY ITTEMP.

    ENDSELECT.

    ENDLOOP.

    u can use this one

    if ittemp[] is not initial.

    SELECT EBELN

    EBELP

    MATNR

    BUKRS

    MENGE

    XBLNR

    LFBNR

    LFGJA

    LFPOS

    LIFNR

    FROM RSEG INTO CORRESPONDING FIELDS OF table ITTEMP_1 for all enties in ittemp

    WHERE BELNR = ITTEMP-BELNR

    AND GJAHR = ITTEMP-GJAHR.

    endif.

    AND HERE U R LOOPING ITFINAL AND MOVING SAME RECORD ITTEMP TO AND ITFINAL AND THERE IS NO USE Y BECAUSE U R NOT WRITNG APPEND OR MODIFY.

    LOOP AT ITFINAL.

    MOVE-CORRESPONDING ITTEMP TO ITFINAL.

    CLEAR ITTEMP.

    CLEAR ITFINAL.

    ENDLOOP.

    reward points to all helpful answers

    kiran.M

    Message was edited by:

    Kiran Machavarapu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 07:13 AM

    Hi

    this program is giving out put

    what u want exactly

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 08:33 AM

    Hi Kiran,

    You can achieve your result by using the following code:

    if itfinal[] is not initial.

    SELECT R~BELNR

    R~GJAHR

    S~EBELN

    S~EBELP

    S~MATNR

    S~BUKRS

    S~MENGE

    S~XBLNR

    S~LFBNR

    S~LFGJA

    S~LFPOS

    S~LIFNR

    FROM RBKP as R

    INNER JOIN RSEG as S

    ON SBELNR = RBELNR

    AND SGJAHR = RGJAHR

    INTO CORRESPONDING FIELDS OF TABLE ITTEMP

    FOR ALL ENTRIES IN itfinal

    WHERE R~XBLNR = ITFINAL-XBLNR

    AND R~LIFNR = ITFINAL-LIFNR

    AND R~BUKRS = ITFINAL-BUKRS.

    endif.

    For performance reason, it will be better the ITTEMP internal table's structure is the same and in the order of the field you are fetching from the table, that way you can delete the INTO CORRESPONDING FIELD statement (This will help in performance).

    Hope this helps.

    Best Regards,

    Fandi.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 11:09 AM

    Hi kiran,

    you can test and use the following code if it is applicable for your requirement.

    Declaration:

    DATA : BEGIN OF it_mseg OCCURS 0,

    mblnr LIKE mkpf-mblnr,

    mjahr LIKE mkpf-mjahr,

    zeile LIKE mseg-zeile,

    bwart LIKE mseg-bwart,

    matnr LIKE mseg-matnr,

    werks LIKE mseg-werks,

    lgort LIKE mseg-lgort,

    lifnr LIKE mseg-lifnr,

    bwtar LIKE mseg-bwtar,

    menge LIKE mseg-menge, "Quantity in MSEG

    ebeln LIKE mseg-ebeln,

    ebelp LIKE mseg-ebelp,

    bukrs LIKE mseg-bukrs,

    END OF it_mseg.

    DATA : BEGIN OF it_ekpo OCCURS 0,

    ebeln LIKE mseg-ebeln,

    ebelp LIKE mseg-ebelp,

    menge LIKE mseg-menge, "Quantity in MSEG

    webre LIKE ekpo-webre,

    END OF it_ekpo.

    DATA : BEGIN OF it_ekko OCCURS 0,

    ebeln LIKE mseg-ebeln,

    aedat LIKE ekko-aedat, "PO Date

    END OF it_ekko.

    DATA : BEGIN OF it_rbkp OCCURS 0,

    belnr LIKE rbkp-belnr,

    gjahr LIKE rbkp-gjahr,

    budat LIKE rbkp-budat,

    xblnr LIKE mkpf-xblnr,

    lifnr LIKE mseg-lifnr,

    bukrs LIKE rbkp-bukrs,

    END OF it_rbkp.

    RANGES : r_xblnr FOR mkpf-xblnr.

    PERFORM getdata.

    &----


    *& Form GETDATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM getdata .

    SELECT mblnr

    mjahr

    budat

    xblnr

    FROM mkpf INTO TABLE itmkpf

    WHERE budat IN s_budat.

    IF sy-subrc NE 0.

    MESSAGE 'No Values exist for the Selection.' TYPE 'S'.

    ENDIF.

    *LOOP AT ITMKPF.

    *MOVE-CORRESPONDING ITMKPF TO ITFINAL.

    IF NOT itmkpf[] IS INITIAL.

    SELECT

    mblnr

    mjahr

    zeile

    bwart

    matnr

    werks

    lgort

    lifnr

    bwtar

    menge

    ebeln

    ebelp

    bukrs

    FROM mseg INTO TABLE it_mseg

    FOR ALL ENTRIES IN itmkpf

    WHERE mblnr = itmkpf-mblnr

    AND mjahr = itmkpf-mjahr.

    IF sy-subrc = 0.

    SORT it_mseg BY mblnr mjahr.

    ENDIF.

    ENDIF.

    IF NOT it_mseg[] IS INITIAL.

    SELECT

    ebeln

    ebelp

    menge

    webre

    FROM ekpo INTO TABLE it_ekpo

    FOR ALL ENTRIES IN it_mseg

    WHERE ebeln = it_mseg-ebeln

    AND ebelp = it_mseg-ebelp.

    IF sy-subrc = 0.

    SORT it_ekpo BY ebeln ebelp.

    ENDIF.

    DELETE it_ekpo WHERE webre NE 'X'.

    SELECT

    ebeln

    aedat

    FROM ekko INTO TABLE it_ekko

    FOR ALL ENTRIES IN it_mseg

    WHERE ebeln = it_mseg-ebeln.

    IF sy-subrc = 0.

    SORT it_ekko BY ebeln.

    ENDIF.

    CLEAR r_xblnr.

    r_xblnr-sign = 'I'.

    r_xblnr-option = 'EQ'.

    LOOP AT itmkpf.

    r_xblnr = itmkpf-xblnr.

    APPEND r_xblnr.

    CLEAR r_xblnr.

    ENDLOOP.

    ENDIF.

    ***********12*******

    IF NOT it_mseg[] IS INITIAL.

    SELECT

    belnr

    gjahr

    budat

    xblnr

    lifnr

    bukrs

    FROM rbkp INTO TABLE it_rbkp

    FOR ALL ENTRIES IN it_mseg

    WHERE xblnr = r_xblnr

    AND lifnr = it_mseg-lifnr

    AND bukrs = it_mseg-bukrs. "26

    IF sy-subrc = 0.

    SORT it_rbkp BY xblnr lifnr bukrs.

    ENDIF.

    CLEAR it_mseg.

    ENDIF..

    IF NOT it_rbkp[] IS INITIAL.

    SELECT

    belnr

    gjahr

    ebeln

    ebelp

    matnr

    bukrs

    menge

    xblnr

    lfbnr

    lfgja

    lfpos

    lifnr

    FROM rseg INTO TABLE ittemp

    WHERE belnr = it_rbkp-belnr

    AND gjahr = it_rbkp-gjahr.

    ENDIF.

    ************12****************

    ***TO GET THE MIRO DATE

    • LOOP AT itfinal.

    • SELECT SINGLE budat

    • FROM rbkp INTO (itfinal-budat1)

    • WHERE belnr = itfinal-belnr "XBLNR

    • AND gjahr = itfinal-gjahr.

    • AND LIFNR = ITFINAL-LIFNR "26

    • AND BUKRS = ITFINAL-BUKRS. "26

    *

    *

    **TO GET THE MIRO QUANTITY

    • SELECT SINGLE menge

    • FROM rseg INTO (itfinal-menge2)

    • WHERE belnr = itfinal-belnr

    • AND gjahr = itfinal-gjahr.

    *

    • MODIFY itfinal.

    • ENDLOOP.

    *

    ENDFORM. " GETDATA

    PERFORM itfinal.

    &----


    *& Form itfinal

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM itfinal .

    IF NOT it_mseg[] IS INITIAL.

    LOOP AT it_mseg.

    MOVE : it_mseg-mblnr TO itfinal-mblnr,

    it_mseg-mjahr TO itfinal-mjahr,

    it_mseg-zeile TO itfinal-zeile,

    it_mseg-bwart TO itfinal-bwart,

    it_mseg-matnr TO itfinal-matnr,

    • it_mseg-werks to itfinal-werks,

    it_mseg-lgort TO itfinal-lgort,

    it_mseg-lifnr TO itfinal-lifnr,

    it_mseg-bwtar TO itfinal-bwtar,

    it_mseg-menge TO itfinal-menge,

    it_mseg-ebeln TO itfinal-ebeln,

    it_mseg-ebelp TO itfinal-ebelp,

    it_mseg-bukrs TO itfinal-bukrs.

    CLEAR itmkpf.

    READ TABLE itmkpf WITH KEY mblnr = it_mseg-mblnr

    mjahr = it_mseg-mjahr

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE : itmkpf-budat TO itfinal-budat,

    itmkpf-xblnr TO itfinal-xblnr.

    CLEAR it_rbkp.

    READ TABLE it_rbkp WITH KEY xblnr = itmkpf-xblnr

    lifnr = it_mseg-lifnr

    bukrs = it_mseg-bukrs

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE : it_rbkp-belnr TO itfinal-belnr,

    it_rbkp-gjahr TO itfinal-gjahr,

    it_rbkp-budat TO itfinal-budat.

    CLEAR ittemp.

    READ TABLE ittemp WITH KEY belnr = it_rbkp-belnr

    gjahr = it_rbkp-gjahr

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE : ittemp-matnr TO itfinal-matnr,

    • ittemp-lfbnr TO itfinal-lfbnr,

    ittemp-lfgja TO itfinal-lfgja,

    ittemp-lfpos TO itfinal-lfpos,

    ittemp-menge TO itfinal-menge2.

    ENDIF.

    ENDIF.

    ENDIF.

    CLEAR it_ekpo.

    READ TABLE it_ekpo WITH KEY ebeln = it_mseg-ebeln

    ebelp = it_mseg-ebelp

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE : it_ekpo-menge TO itfinal-menge,

    it_ekpo-webre TO itfinal-webre.

    ENDIF.

    CLEAR it_ekko.

    READ TABLE it_ekko WITH KEY ebeln = it_mseg-ebeln

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE : it_ekko-aedat TO itfinal-aedat.

    ENDIF.

    APPEND itfinal.

    CLEAR: itfinal,it_mseg.

    ENDLOOP.

    ENDIF.

    ENDFORM. " itfinal

    you can modify the code according to your requirements.

    i tried my best to make better performance.

    i hope this code is helpful for you and if yes reward with points.

    Regards,

    Vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 22, 2007 at 06:54 AM

    Thanks a lot,

    K.Kiran.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.