Skip to Content
0
Former Member
Jan 19, 2006 at 01:18 PM

Problem in Extracting Dataset from Z FM for Zdatasource

12 Views

hi,

I have created a Z fm of extracting data in Z datasource and i ahve written code for it.

But everytime it returns me

0 dataset extracted...

i debugged it....and found data in E_T_DTFIAR_1

and till dat it is working fine ( wat i m assuming),

after dat it is going to some other forms(like data transfer ) and some events.

and finally throwing 0 data record found.

here is the code..........can anyone tell me wat i m missing in this code...

FUNCTION ZFIE*.

*"----


""Local interface:

*" IMPORTING

*" VALUE(I_DSOURCE) TYPE SBIWA_S_INTERFACE-ISOURCE

*" VALUE(I_REQUNR) TYPE SBIWA_S_INTERFACE-REQUNR OPTIONAL

*" VALUE(I_MAXSIZE) TYPE SBIWA_S_INTERFACE-MAXSIZE OPTIONAL

*" VALUE(I_INITFLAG) TYPE SBIWA_S_INTERFACE-INITFLAG OPTIONAL

*" VALUE(I_UPDMODE) TYPE SBIWA_S_INTERFACE-UPDMODE OPTIONAL

*" VALUE(I_DATAPAKID) TYPE SBIWA_S_INTERFACE-DATAPAKID OPTIONAL

*" TABLES

*" I_T_SELECT TYPE SBIWA_T_SELECT OPTIONAL

*" I_T_FIELDS TYPE SBIWA_T_FIELDS OPTIONAL

*" E_T_DTFIAR_1 STRUCTURE ZFIE_ (extractor structure) OPTIONAL

*" EXCEPTIONS

*" NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

*"----


TABLES: VBREVE, ZFIE_EXT_REV, VBAK, VBRP, VBPA, KNA1..

*....... steering flags

STATICS: L_CURSOR TYPE CURSOR,

L_OPEN_CURSOR_FLAG LIKE C_OFF,

L_LAST_DATA_FLAG LIKE C_OFF.

*....... PACKAGE-SIZE for SELECT-Statement

STATICS: L_PACKAGE_SIZE LIKE SY-TABIX.

  • first call - initialization **********************

IF NOT ( I_INITFLAG IS INITIAL ).

  • IF NOT ( G_FLAG_INTERFACE_INITIALIZED IS INITIAL ).

**.... Invalid second initialization call -> error exit

  • IF 1 = 2. MESSAGE E008(R3). ENDIF. "only for Where-used list

  • LOG_WRITE 'E' "message type

  • 'R3' "message class

  • '008' "message number

  • ' ' "message variable 1

  • ' '. "message variable 2

  • RAISE ERROR_PASSED_TO_MESS_HANDLER.

  • ENDIF.

*.. check DataSource validity

CASE I_DSOURCE.

WHEN C_ISOURCE_DTFIAR_1.

WHEN OTHERS.

IF 1 = 2.

MESSAGE E009(R3) WITH I_DSOURCE. "only for Where-used list

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.

*.. Check for supported update mode

  • CASE I_UPDMODE.

  • WHEN 'F'.

  • WHEN OTHERS.

  • IF 1 = 2.

  • MESSAGE E011(R3) WITH I_UPDMODE. "only for Where-used list

  • ENDIF.

  • LOG_WRITE 'E' "message type

  • 'R3' "message class

  • '011' "message number

  • I_UPDMODE "message variable 1

  • ' '. "message variable 2

  • RAISE ERROR_PASSED_TO_MESS_HANDLER.

  • ENDCASE.

APPEND LINES OF I_T_SELECT TO G_T_SELECT.

*.. Fill parameter buffer for data extraction calls

G_S_INTERFACE-REQUNR = I_REQUNR.

G_S_INTERFACE-ISOURCE = I_DSOURCE.

G_S_INTERFACE-MAXSIZE = I_MAXSIZE.

G_S_INTERFACE-INITFLAG = I_INITFLAG.

G_S_INTERFACE-UPDMODE = I_UPDMODE.

G_S_INTERFACE-DATAPAKID = I_DATAPAKID.

G_FLAG_INTERFACE_INITIALIZED = SBIWA_C_FLAG_ON.

  • Fill field list table for an optimized select statement

  • (in case that there is no 1:1 relation between InfoSource fields

  • and database table fields this may be far from beeing trivial)

APPEND LINES OF I_T_FIELDS TO G_T_FIELDS.

*.. calculate PACKAGE-SIZE for SELECT-Statement (approximate)

L_PACKAGE_SIZE = G_S_INTERFACE-MAXSIZE / 12.

*.. fill selection criterias to global ranges

  • second and further calls - data selection *************

ELSE.

*.. clear table for export data

CLEAR: E_T_DTFIAR_1.

REFRESH: E_T_DTFIAR_1.

IF L_OPEN_CURSOR_FLAG IS INITIAL.

*.... open cursor

OPEN CURSOR WITH HOLD L_CURSOR FOR

SELECT

REFERENCE_DOC REF_DOC_ITM GL_ACCOUNT YEAR_PERIOD AMOUNT_DOC_CURR

CURRENCY PROFIT_CENTER GL_OFFSET BUSINESS_AREA COMPANY_CODE

REVENUE_STATUS SOLD_TO FISCAL_YEAR PERIOD DOCUMENT_TYPE

AMOUNT_COMPANY AMOUNT_PROFT_CTR BILLING_DATE PLANT SALES_OFFICE

SALES_GROUP SALES_DISTRICT END_USER_COUNTRY PROD_HIERARCHY

MATERIAL MATERIAL_COST SALES_ORG DISTR_CHANNEL NUMBER_OF_NODES

ORDER_DATE MATERIAL_GROUP AAG CONTRACT QUANTITY DAF_NUMBER

BILLING_DATE

FROM ZFIE_EXT_REV

WHERE

RECORD_TYPE ='DEF'.

SELECT SINGLE VBELN FROM VBREVE INTO ITAB_REVENUE-REFDOCNR.

L_OPEN_CURSOR_FLAG = C_ON.

ENDIF. "L_OPEN_CURSOR_FLAG = C_OFF

IF L_PACKAGE_SIZE <> 0.

*.... fetch next package

FETCH NEXT CURSOR L_CURSOR

APPENDING CORRESPONDING FIELDS OF TABLE LT_DEF_REV

PACKAGE SIZE L_PACKAGE_SIZE.

*.... process selected data

PERFORM PROCESS_SEL_DATA_AR1 TABLES LT_DEF_REV E_T_DTFIAR_1.

*.... check, if cursor has to be closed

DESCRIBE TABLE LT_DEF_REV LINES SY-TFILL.

IF SY-TFILL LT L_PACKAGE_SIZE.

CLOSE CURSOR L_CURSOR.

L_LAST_DATA_FLAG = 'X'.

ENDIF.

ENDIF.

ENDIF.

ENDFUNCTION.

----


  • FORM PROCESS_SEL_DATA_AR1 *

----


FORM PROCESS_SEL_DATA_AR1 TABLES SEL_DATA STRUCTURE LT_DEF_REV

EXP_DATA STRUCTURE ZFIE_BIW_DEF_HIS.

*....... local data declarations

if not SEL_DATA[] is initial.

move sel_data[] to exp_data[].

  • SELECT POPUPO VBELN_N POSNR_N RVAMT ACCPD PAOBJNR SAKUR SAMMG

  • REFFLD ERDAT ERZET BUDAT REVFIX

  • APPENDING CORRESPONDING FIELDS OF TABLE it_vbreve

*

  • FROM VBREVE

  • WHERE VBELN = ITAB_REVENUE-REFDOCNR

  • AND POSNR = SEL_DATA-REF_DOC_ITM

  • AND BUKRS = SEL_DATA-COMPANY_CODE

  • AND BDJPOPER = SEL_DATA-YEAR_PERIOD.

*move it_vbreve[] to exp_data[].

*move exp_data to e_t_data.

ENDif.

ENDFORM.

any help! plz..

rdgs,

San!