Application Development and Automation 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: 
Read only

outbound flat file format

Former Member
0 Likes
752

I'm trying to download a sap format to non sap format

when I download a particular file from application server, data is in string format. so if I have to change the file structure according to Non sap format, I may require to read this file into some internal table. but as it is a continuous string i'm not able to split it into different fields. how can i proceed?

Can anybody suggest me what to do

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
703

ABAp,

To get the file from App.server you have to use data extracts.

EX :

data : s_filename(400),

I_TEMP(400),

DATA : BEGIN OF I_FINALTAB OCCURS 0,

QMART(3),

QMNUM LIKE VIQMEL-QMNUM,

MNCOD(8),

PSTER TYPE DATUM,

STAT(11),

TXT30 LIKE TJ02T-TXT30,

STRMN(9),

LTRMN LIKE VIQMEL-LTRMN,

URCOD(9),

QMTXT LIKE VIQMEL-QMTXT,

POST_CODE1 LIKE ADRC-POST_CODE1,

BZIRK LIKE VBKD-BZIRK,

KDMAT LIKE VBAP-KDMAT,

END OF I_FINALTAB.

OPEN DATASET S_FILENAME FOR input IN TEXT MODE.

DO.

READ DATASET s_filename INTO I_TEMP.

IF SY-SUBRC <> 0.

EXIT.

ELSE.

move I_TEMP to I_FINALTAB.

append I_FINALTAB.

clear I_FINALTAB.

ENDIF.

ENDDO.

CLOSE DATASET s_filename .

clear v_flag.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

CODEPAGE = 'IBM'

FILENAME = T_PATH

FILETYPE = 'ASC'

TABLES

DATA_TAB = I_FINALTAB.

IF SY-SUBRC <> 0.

MESSAGE e013(zmamin) WITH 'Unable to download the File'.

ELSE.

MESSAGE i013(zmamin) WITH 'File downloaded Successfully'.

LEAVE.

ENDIF.

CLOSE DATASET s_filename .

This will solve your problem.

Pls. Mark if useful

5 REPLIES 5
Read only

Former Member
0 Likes
703

Hi,

Check if the following link is useful.

http://www.sapdevelopment.co.uk/reporting/rep_capturerep.htm

regards,

Priya.

Read only

Former Member
0 Likes
703

Hi,

There must be some separator which separates the columns even in the string(Like a space , or a comma, or a | etc).

Once you have that string in a variable, you can use the split statement.

do.

read dataset dsn into itab-string.

if sy-subrc = 0.

split itab-string at '|' into itab_new-field1 itab_new-fiel2 itab_new-field3.....

append itab_new.

clear itab_new.

else.

exit.

endif.

enddo.

Regards,

ravi

Read only

Former Member
0 Likes
704

ABAp,

To get the file from App.server you have to use data extracts.

EX :

data : s_filename(400),

I_TEMP(400),

DATA : BEGIN OF I_FINALTAB OCCURS 0,

QMART(3),

QMNUM LIKE VIQMEL-QMNUM,

MNCOD(8),

PSTER TYPE DATUM,

STAT(11),

TXT30 LIKE TJ02T-TXT30,

STRMN(9),

LTRMN LIKE VIQMEL-LTRMN,

URCOD(9),

QMTXT LIKE VIQMEL-QMTXT,

POST_CODE1 LIKE ADRC-POST_CODE1,

BZIRK LIKE VBKD-BZIRK,

KDMAT LIKE VBAP-KDMAT,

END OF I_FINALTAB.

OPEN DATASET S_FILENAME FOR input IN TEXT MODE.

DO.

READ DATASET s_filename INTO I_TEMP.

IF SY-SUBRC <> 0.

EXIT.

ELSE.

move I_TEMP to I_FINALTAB.

append I_FINALTAB.

clear I_FINALTAB.

ENDIF.

ENDDO.

CLOSE DATASET s_filename .

clear v_flag.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

CODEPAGE = 'IBM'

FILENAME = T_PATH

FILETYPE = 'ASC'

TABLES

DATA_TAB = I_FINALTAB.

IF SY-SUBRC <> 0.

MESSAGE e013(zmamin) WITH 'Unable to download the File'.

ELSE.

MESSAGE i013(zmamin) WITH 'File downloaded Successfully'.

LEAVE.

ENDIF.

CLOSE DATASET s_filename .

This will solve your problem.

Pls. Mark if useful

Read only

Former Member
0 Likes
703

Hi,

as has been cleared by Ravi in case there is a separator that is used then you can use 'SPLIT'.

otherwise if it's a continous string with no separator then you need to know the structure and the lenght of each field to be put for NON-SAP system.

then you'll have to assign values to table using offset

say itab-first = variable+0(10)

itab-second = variable+10(5)

..... so on.

Hope this helps you

Regards

Nishant

Read only

Former Member
0 Likes
703

Thanks a lot friends