FUNCTION ZSCN_BILLING. TABLES: ZEXT_BILLING. FIELD-SYMBOLS <fs_billing> TYPE ZEXT_BILLING. STATICS: s_index TYPE I. "" STATICS Key word was used so that it can hold t he data between FM calls STATICS: counter TYPE I. DATA: WA_billing TYPE ZEXT_BILLING . ASSIGN WA_billing TO <fs_billing> . DATA: L_S_SELECT TYPE SRSC_S_SELECT. STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE, S_COUNTER_DATAPAKID LIKE SY-TABIX . RANGES: L_R_CUST FOR ZEXT_BILLING-CUST. "" Range table to accept selection TYPES : BEGIN OF cust, CUST TYPE /BI0/OICUSTOMER , END OF cust. STATICS it_cust TYPE STANDARD TABLE OF cust. "List of Input Parameter ( CUS T), STATICS is used not to lose list between FM calls. DATA : wa_cust TYPE cust. DATA : lv_table TYPE STANDARD TABLE OF ZIF_ZPROXY_SCN_BILLING=>VAR_OUT WITH EMPTY KEY , wa_table TYPE ZIF_ZPROXY_SCN_BILLING=>VAR_OUT . "" Using Interface of the Proxy Procedure created earlier FIELD-SYMBOLS <fs_table> TYPE ZIF_ZPROXY_SCN_BILLING=>VAR_OUT. * Initialization mode (first call by SAPI) or data transfer mode * (following calls) ? IF I_INITFLAG = SBIWA_C_FLAG_ON. * CASE I_DSOURCE. WHEN 'ZDS_SCN_BILLING'. WHEN OTHERS. IF 1 = 2. MESSAGE E009(R3). ENDIF. LOG_WRITE 'E' "message type 'R3' "message class '009' "message number I_DSOURCE "message variable 1 ' '. "message variable 2 RAISE ERROR_PASSED_TO_MESS_HANDLER. ENDCASE. APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT. * Fill parameter buffer for data extraction calls S_S_IF-REQUNR = I_REQUNR. S_S_IF-DSOURCE = I_DSOURCE. S_S_IF-MAXSIZE = I_MAXSIZE . APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS. s_index = 1 . "" Initializign s_index in the first call , this would not be done second time. ELSE. "Initialization mode or data extraction ? IF S_COUNTER_DATAPAKID = 0. LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CUST'. MOVE-CORRESPONDING L_S_SELECT TO L_R_CUST. APPEND L_R_CUST. ENDLOOP. SELECT DISTINCT CUST INTO TABLE it_cust FROM ZCUST_LIST WHERE CUST IN L_R_CUST . SORT it_cust by CUST . describe table it_cust lines counter. "" Making a list of Input Paramet er ( Cust here) to be supplied ENDIF. "First data package ? DATA: index2 type I . index2 = s_index + 1 . LOOP AT it_cust INTO wa_cust FROM s_index to index2. CALL DATABASE PROCEDURE ZPROXY_SCN_BILLING EXPORTING IP_CUST1 = wa_cust-CUST(6) IMPORTING VAR_OUT = lv_table. "" this would contain result of procedure call IF lv_table[] IS NOT INITIAL . LOOP AT lv_table ASSIGNING <fs_table> . MOVE-CORRESPONDING <fs_table> to <fs_billing> . APPEND <fs_billing> to E_T_DATA. ENDLOOP. UNASSIGN <fs_table> . ENDIF . ENDLOOP. IF index2 > counter + 1 . "" Index2 = counter means, we called the procedure with all input parameter, in the next call NO_MORE_DATA would b e raised. RAISE NO_MORE_DATA . ELSE. s_index = index2 + 1 . ENDIF. ENDIF. ENDFUNCTION. "Initialization mode or data extraction ?