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: 

help!about the open dateset

Former Member
0 Kudos

hi,

I want to upload data to sap server in txt format, now i want use the program as follows:

open dataset file for output IN text MODE encoding default.

loop at itab.

TRANSFER itab TO file.

endloop.

close dataset file.

in this way ,the text is no separated by separator. How separated by separator(, or tab),can somebody tell me ,ths.

sophia

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Data: record type string,

sep type c value ','.

open dataset file for output IN text MODE encoding default.

loop at itab.

concatenate itab-field1

itab-fiel2

into record

separated by sep.

TRANSFER record TO file.

endloop.

close dataset file.

5 REPLIES 5

former_member386202
Active Contributor
0 Kudos

Hi,

Declare fields in ur itab as a character n pass separater int that field as ' space or whatever u want n then download. This is the only way.

Regards,

Prashant

Former Member
0 Kudos

do this way....

If u want to Concatenate the components Dynamically use the Field symbols concept.

Eg:

field-symbols: <fcomp> type any.

DATA : V_sTR TYPE STRING.

Loop at Itab INTO WA..

Do .

ASSIGN-COMPONENT SY-INDEX OF STRUCTURE WA TO <FCOMP>

CASTING TYPE C.

IF SY-SUBRC NE 0.

EXIT.

ELSE.

CONCATENATE V_STR <FCOMP> TO V_STR

SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

ENDIF.

Enddo.

TRANSFER V_STR TO P_FILE.

ENDLOOP.

Regards

Vasu

Former Member
0 Kudos

Data: record type string,

sep type c value ','.

open dataset file for output IN text MODE encoding default.

loop at itab.

concatenate itab-field1

itab-fiel2

into record

separated by sep.

TRANSFER record TO file.

endloop.

close dataset file.

Former Member
0 Kudos

Hi Sophia,

This is kiran kumar.G(working in SAP).i have develop a small code for u for ur problem.U have to copy the below code and execute it.And trace my code ok.Then ur problem will be solved.

If u r satisfy with my answer give me REWARD POINTS.

HAVE A NICE DAY..

CODE:

----


  • Internal Table

----


DATA: BEGIN OF itab OCCURS 0,

text(50),

END OF itab.

----


  • Append data to Internal Table

----


itab-text = 'DEMO BDC FIRST LINE'.

APPEND itab.

itab-text = 'DEMO BDC SECOND LINE'.

APPEND itab.

----


  • OPEN THE DATASET

----


OPEN DATASET 'ZBDCDEMO' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

----


  • Transfer the data to APPSERVER

----


LOOP AT itab.

TRANSFER itab TO 'ZBDCDEMO'.

ENDLOOP.

----


  • Close the Dataset

----


CLOSE DATASET 'ZBDCDEMO'.

Former Member
0 Kudos

thans your help.

sophia