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: 

BW FM to extract Data

Former Member
0 Kudos

Hi All ,

I am new to this kind of extraction in BW ,

Would like to know couple things

My code

* Select record from FIFO DSO .
      OPEN CURSOR WITH HOLD S_CURSOR1 FOR
      SELECT /BIC/MATERIAL
             /BIC/PLANT
             /BIC/RECP_DATE
             /BIC/UPD_DATE
             /BIC/WEEK_END
             /BIC/RECP_QTY
              BASE_UOM
              RECORDMODE
      FROM /BIC/AFF_O01300
                   WHERE /bic/material  IN LR_MATERIAL
                   and /bic/plant     IN LR_PLANT.                  "First data package ?

*Seelct Records from new GRs
      OPEN CURSOR WITH HOLD S_CURSOR2 FOR
       SELECT /BIC/DOC_DATE
               /BIC/MATERIAL
               /BIC/PLANT
               /BIC/MOVETYPE
               /BIC/QUANT_B
                BASE_UOM
               RECORDMODE
       FROM /bic/aff_o00500
                     WHERE /bic/material  IN LR_MATERIAL
                       and /bic/plant     IN LR_PLANT
                       and /BIC/MOVETYPE = '101'.    "First data package ?


*Select SOH
      OPEN CURSOR WITH HOLD S_CURSOR3 FOR
      SELECT /BIC/WEEK_END
             /BIC/PLANT
             /BIC/MATERIAL
             /BIC/STK_ONOQW
             BASE_UOM
             RECORDMODE
      FROM /bic/aff_o00700
                         WHERE /BIC/WEEK_END = lv_week_end
                           and /bic/material  IN LR_MATERIAL
                           and /bic/plant     IN LR_PLANT
                             .     "First data package ?

    ENDIF.

    Do .
* High volume of data. use package in loop
      FETCH NEXT CURSOR S_CURSOR1
                     APPENDING CORRESPONDING FIELDS
                    OF TABLE gT_GR_FIFO
                     PACKAGE SIZE C_package.

      IF SY-SUBRC <> 0.
        CLOSE CURSOR S_CURSOR1.
        EXIT.
*         RAISE NO_MORE_DATA.
      ENDIF.
    ENDDO.

    Do .
* High volume of data .use package in loop
      FETCH NEXT CURSOR S_CURSOR2
                 APPENDING CORRESPONDING FIELDS
                OF TABLE gt_STK_GR_NEW
                PACKAGE SIZE C_package.

      IF SY-SUBRC <> 0.
        CLOSE CURSOR S_CURSOR2.
        EXIT.
*         RAISE NO_MORE_DATA.
      ENDIF.
    ENDDO.

    Do .
* High volume of data use package in loop
      FETCH NEXT CURSOR S_CURSOR3
                 APPENDING CORRESPONDING FIELDS
                OF TABLE gt_MATL_ACT_SOH
                PACKAGE SIZE C_package.

      IF SY-SUBRC <> 0.
        CLOSE CURSOR S_CURSOR3.
        EXIT.
*         RAISE NO_MORE_DATA.
      ENDIF.
    ENDDO.

As you see I am opening 3 three cursors .

the 1 st fetch statement will be retreving about couple of million records .

through search on this I found that using fetch in loop with package would not cause any internal table space problem and

performance issues .

But not sure wheter this is the right approach .

Any suggestions will be great .

Thanks

Vinay

.

1 REPLY 1

Former Member
0 Kudos
OPEN CURSOR WITH HOLD S_CURSOR1 FOR SELECT /BIC/MATERIAL
/BIC/PLANT
/BIC/RECP_DATE 
/BIC/UPD_DATE 
/BIC/WEEK_END /
BIC/RECP_QTY 
BASE_UOM 
RECORDMODE 
FROM /BIC/AFF_O01300 WHERE /bic/material IN LR_MATERIAL and /bic/plant IN LR_PLANT. 
"First data package ? *Seelct Records from new GRs 
OPEN CURSOR WITH HOLD S_CURSOR2 FOR SELECT 
/BIC/DOC_DATE 
/BIC/MATERIAL 
/BIC/PLANT 
/BIC/MOVETYPE 
/BIC/QUANT_B 
BASE_UOM 
RECORDMODE 
     FROM /bic/aff_o00500 WHERE /bic/material IN LR_MATERIAL and /bic/plant IN LR_PLANT and /BIC/MOVETYPE = '101'. 
*Select SOH 
OPEN CURSOR WITH HOLD S_CURSOR3 FOR SELECT 
 /BIC/WEEK_END 
/BIC/PLANT 
/BIC/MATERIAL 
/BIC/STK_ONOQW 
BASE_UOM 
RECORDMODE 
FROM /bic/aff_o00700 WHERE /BIC/WEEK_END = lv_week_end and /bic/material IN LR_MATERIAL and /bic/plant IN LR_PLANT . 
ENDIF. Do . 
* High volume of data. use package in loop 
FETCH NEXT CURSOR S_CURSOR1 APPENDING CORRESPONDING FIELDS OF TABLE gT_GR_FIFO PACKAGE SIZE C_package. 
IF SY-SUBRC 0.
 CLOSE CURSOR S_CURSOR1. 
EXIT. 
* RAISE NO_MORE_DATA. 
ENDIF. 
ENDDO. 

Do . * High volume of data .use package in loop 
FETCH NEXT CURSOR S_CURSOR2 APPENDING CORRESPONDING FIELDS OF TABLE gt_STK_GR_NEW PACKAGE SIZE C_package. 
IF SY-SUBRC 0. 
CLOSE CURSOR S_CURSOR2.
 EXIT. 
* RAISE NO_MORE_DATA. 
ENDIF. 
ENDDO.
 Do . * High volume of data use package in loop 
FETCH NEXT CURSOR S_CURSOR3 APPENDING CORRESPONDING FIELDS OF TABLE gt_MATL_ACT_SOH PACKAGE SIZE C_package.
 IF SY-SUBRC 0.
 CLOSE CURSOR S_CURSOR3. 
EXIT. 
* RAISE NO_MORE_DATA. 
ENDIF. 
ENDDO