Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Need to extract data from tables

Hello Experts i need to extarct data from r/3 source and generate a flat file or directly load into sql tables. can some one help me out with that, below is the code i am using but it is not storing in flatfiles, can some one let me know what am i missing in the below code.

&----


*& Report ZFIGLEXT_01

*&

&----


*&

*&

&----


REPORT ZFIGLEXT_01.

tables: /BIC/OHZFIGL_002.

*PARAMETERS:

  • DOWNDIR(20) DEFAULT 'C:\ABAP\'.

*DATA:

  • W_FILENAME(128).

select * from /BIC/OHZFIGL_002 client specified.

write:

/BIC/OHZFIGL_002-AC_DOC_NO,

/BIC/OHZFIGL_002-COMP_CODE,

/BIC/OHZFIGL_002-FISCPER,

/BIC/OHZFIGL_002-FISCVARNT,

/BIC/OHZFIGL_002-GL_ACCOUNT,

/BIC/OHZFIGL_002-ITEM_NUM,

/BIC/OHZFIGL_002-ACCT_TYPE,

/BIC/OHZFIGL_002-AC_DOC_TYP,

/BIC/OHZFIGL_002-ALLOC_NMBR,

/BIC/OHZFIGL_002-BUS_AREA,

/BIC/OHZFIGL_002-CHRT_ACCTS,

/BIC/OHZFIGL_002-CLEAR_DATE,

/BIC/OHZFIGL_002-CLR_DOC_NO,

/BIC/OHZFIGL_002-COORDER,

/BIC/OHZFIGL_002-COSTCENTER,

/BIC/OHZFIGL_002-CO_AREA,

/BIC/OHZFIGL_002-CREATEDON,

/BIC/OHZFIGL_002-CREDIT_DC,

/BIC/OHZFIGL_002-CREDIT_LC,

/BIC/OHZFIGL_002-DEBIT_DC,

/BIC/OHZFIGL_002-DEBIT_LC,

/BIC/OHZFIGL_002-DEB_CRE_DC,

/BIC/OHZFIGL_002-DEB_CRE_LC,

/BIC/OHZFIGL_002-DOC_CURRCY,

/BIC/OHZFIGL_002-DOC_DATE,

/BIC/OHZFIGL_002-FI_DOCSTAT,

/BIC/OHZFIGL_002-FUNC_AREA,

/BIC/OHZFIGL_002-LOC_CURRCY,

/BIC/OHZFIGL_002-ORG_DOC_CC,

/BIC/OHZFIGL_002-ORG_DOC_CO,

/BIC/OHZFIGL_002-ORG_DOC_NO,

/BIC/OHZFIGL_002-ORG_DOC_YR,

/BIC/OHZFIGL_002-PART_PRCTR,

/BIC/OHZFIGL_002-PBUS_AREA,

/BIC/OHZFIGL_002-PCOMPANY,

/BIC/OHZFIGL_002-PLANT,

/BIC/OHZFIGL_002-POSTXT,

/BIC/OHZFIGL_002-POST_KEY,

/BIC/OHZFIGL_002-PROFIT_CTR,

/BIC/OHZFIGL_002-PSTNG_DATE,

/BIC/OHZFIGL_002-RECORDMODE,

/BIC/OHZFIGL_002-REF_DOC_NO,

/BIC/OHZFIGL_002-REF_KEY3,

/BIC/OHZFIGL_002-SP_GL_IND,

/BIC/OHZFIGL_002-VALUE_DATE,

/BIC/OHZFIGL_002-WBS_ELEMT.

endselect.

  • CALL FUNCTION 'WS_DOWNLOAD'

  • EXPORTING

  • FILENAME = W_FILENAME

  • FILETYPE = 'ASC'.

write: /'hello world'.

thank you,

Kris

replied

Hello Kris

How r u ?

try using this program, modify according to ur need.

REPORT ZBW_FF_TEST.

TABLES: KNA1.

DATA: BEGIN OF IT_KNA1 OCCURS 0,

KUNNR LIKE KNA1-KUNNR,

NAME1 LIKE KNA1-NAME1,

LAND1 LIKE KNA1-LAND1,

END OF IT_KNA1.

SELECT KUNNR NAME1 LAND1 FROM KNA1 INTO TABLE IT_KNA1.

LOOP AT IT_KNA1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\FLAT_FILE.TXT'

FILETYPE = 'ASC'

TABLES

DATA_TAB = IT_KNA1.

ENDLOOP.

Hope this helps.

Best Regards....

Sankar Kumar

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question