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: 

how to write empty line in text file

Former Member
0 Kudos

hey

i want to insert one empty line in text file.

how to write this.

i declared

data: emptyrec(240) type c value space,

and used

TRANSFER emptyrec to e_file.

but its not inserting empty line in the record.

is there any special way have to do.

ambichan.

8 REPLIES 8

Former Member
0 Kudos

Hi ambichan,

Try using the ASCII value for Line Feed (0A) in your line and then see.

Regards,

Anand Mandalika.

0 Kudos

By the way, I'm able to get a blank line with the code you are using too. Can you give the complete code ?

0 Kudos

hey

i am using in windows environment.

also i tried like this,

emptyrec(2) type x value '0A',

it gives me inserting empty space with starting (# hash symbol-1char) in ABAP screen(when i doouble click the text file from AL11.)

when i download and open the text file in excel its in braces{ like this.

does my way of declaring ascii value is correct?

ambichan.

Former Member
0 Kudos

hai anand,

I am posting the code snippet.

i have commented that transfer line in '----


' like this

pls refer below.

ambichan

DATA: PAGENO(4) TYPE N VALUE 1,

DATAKBN(2) TYPE N VALUE 1,

SUBNO(3) TYPE N VALUE 1,

VPAGENO(4) TYPE C,

VDATAKBN(2) TYPE C,

VSUBNO(3) TYPE C,

VREC(255) TYPE C,

VRECORD(255) TYPE C,

EMPTYREC(255) TYPE C VALUE SPACE,

VCODE(10) TYPE C,

VNAME2(35) TYPE C,

VPAYDAT(10) TYPE C,

VSGTXT(60) TYPE C VALUE SPACE,

VSGTXT1(10) TYPE C,

VKINGAKU(15) TYPE C VALUE SPACE,

VBIKKO(30) TYPE C VALUE SPACE,

VBELNR(10) TYPE C VALUE SPACE,

VDMBTR(15) TYPE C,

VGLT0-KSLVT(15) TYPE C,

VGLT0-TSL01(15) TYPE C,

VGLT0-TSL02(15) TYPE C,

VGLT0-TSL03(15) TYPE C,

VGLT0-TSL04(15) TYPE C,

VGLT0-TSL05(15) TYPE C,

VKIN(15) TYPE C,

VTEGA(15) TYPE C.

FORM FRM_OUTPUT_DATA.

SORT ITAB_OUTPUT_SUMMARY BY LIFNR DTYPE.

SORT ITAB_OUTPUT_ITEMS BY LIFNR DTYPE BELNR.

IF P_DISP = 'X'."checkボクスを選ぶ場合、ファイル作成処理へ行く

OPEN DATASET E_FILE FOR OUTPUT IN TEXT MODE.

IF SY-SUBRC <> 0.

WRITE: 'error',SY-SUBRC.

EXIT.

ENDIF.

LOOP AT ITAB_LIFNR.

PERFORM LISTDATA.

PAGENO = PAGENO + 1.

SUBNO = 1.

ENDLOOP.

CLOSE DATASET E_FILE."&#12501;&#12449;&#12452;&#12523;&#12463;&#12525;&#12540;&#12474;

ENDFORM. " End of frm_output_data

FORM LISTDATA.

DATA:

WK_PAY_AMOUNT LIKE BSEG-DMBTR, " &#32020;&#25903;&#25173;&#38989;&#31639;&#20986;&#29992;

VWK_PAY_AMOUNT(15) TYPE C,

GLT0-TSL05_VAL LIKE GLT0-TSL05.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 1.

  • BSIK-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

GLT0-TSL01 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 2. " &#21306;&#20998;&#65306;2

GLT0-TSL02 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 3. " &#21306;&#20998;&#65306;3

GLT0-TSL03 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 4. " &#21306;&#20998;&#65306;4

GLT0-TSL04 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 5. " &#21306;&#20998;&#65306;5

GLT0-TSL05 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

  • glt0-tsl05 = glt0-tsl05 + glt0-tsl04.

WK_PAY_AMOUNT = GLT0-TSL05 + GLT0-TSL04.

*

  • CHECK WK_SUBRC = 0.

BSEG-KOART = ' '. &#24773;&#22577;&#19981;&#35201;

CLEAR: BSEG-SGTXT, BSEG-DMBTR, TGSBT-GTEXT, BKPF-BELNR.

BSEG-KOART = 'Y'. " &#12501;&#12521;&#12464;&#65306;&#12504;&#12483;&#12480;&#12395;&#30456;&#27578;&#38989;&#12434;&#20986;&#21147;

CLEAR: BSAK-DMBTR.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 6. " &#21306;&#20998;&#65306;6

BSAK-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

WK_PAY_AMOUNT = WK_PAY_AMOUNT - BSAK-DMBTR.

WRITE : / PAGENO,

SUBNO,

DATAKBN,

ITAB_LIFNR-LIFNR,

ITAB_LIFNR-NAME2(25),

P_PAY_T,

GLT0-TSL01,

GLT0-TSL02,

GLT0-TSL03,

GLT0-TSL04,

GLT0-TSL05.

VPAGENO = PAGENO.

VSUBNO = SUBNO.

DATAKBN = 1.

VDATAKBN = DATAKBN.

VCODE = ITAB_LIFNR-LIFNR.

VNAME2 = ITAB_LIFNR-NAME2.

VPAYDAT = P_PAY_T.

VGLT0-TSL01 = GLT0-TSL01.

VGLT0-TSL02 = GLT0-TSL02.

VGLT0-TSL03 = GLT0-TSL03.

VGLT0-TSL04 = GLT0-TSL04.

VGLT0-TSL05 = GLT0-TSL05.

CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT VKINGAKU

VBIKKO VBELNR VGLT0-TSL01 VGLT0-TSL02 VGLT0-TSL03

VGLT0-TSL04 VGLT0-TSL05 INTO VREC SEPARATED BY ','.

CLEAR: BSAK-DMBTR, BSID-DMBTR, BSAD-DMBTR, BSEG-DMBTR, BSIK-DMBTR,

WK_10 , WK_11 , GLT0-TSL05.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 7. " &#21306;&#20998;&#65306;7

BSID-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

WK_PAY_AMOUNT = WK_PAY_AMOUNT - BSID-DMBTR.

  • &#37109;&#36865;&#26009;&#12398;&#20986;&#21147;&#20966;&#29702;

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 8. " &#21306;&#20998;&#65306;8

BSAD-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

WK_PAY_AMOUNT = WK_PAY_AMOUNT - BSAD-DMBTR.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 9. " &#21306;&#20998;&#65306;9

BSEG-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

WK_PAY_AMOUNT = WK_PAY_AMOUNT - BSEG-DMBTR.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 10.

WK_10 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

READ TABLE ITAB_OUTPUT_SUMMARY

WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 11.

WK_11 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.

GLT0-TSL05 = WK_PAY_AMOUNT - WK_10 - WK_11.

WK_PAY_AMOUNT = WK_PAY_AMOUNT - GLT0-TSL05.

VWK_PAY_AMOUNT = WK_PAY_AMOUNT.

VKIN = WK_10.

VTEGA = WK_11.

CONCATENATE VREC VWK_PAY_AMOUNT VKIN VTEGA INTO

VRECORD SEPARATED BY ','.

TRANSFER VRECORD TO E_FILE.

WRITE :

VWK_PAY_AMOUNT,

WK_10,

WK_11.

WRITE:/.

BSEG-KOART = 'X'. " &#12501;&#12521;&#12464;&#65306;&#35531;&#27714;&#37329;&#38989;&#12434;&#20986;&#21147;

LOOP AT ITAB_OUTPUT_ITEMS WHERE LIFNR = ITAB_LIFNR-LIFNR

AND DTYPE = 5. " &#21306;&#20998;&#65306;5

BSEG-SGTXT = ITAB_OUTPUT_ITEMS-SGTXT. " &#26126;&#32048;&#12486;&#12461;&#12473;&#12488;

GLT0-KSLVT = ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO. " &#37329;&#38989;

TGSBT-GTEXT = ITAB_OUTPUT_ITEMS-GTEXT. BKPF-BELNR = ITAB_OUTPUT_ITEMS-BELNR.

SUBNO = SUBNO + 1.

VSUBNO = SUBNO.

DATAKBN = 2.

VDATAKBN = DATAKBN.

VGLT0-KSLVT = GLT0-KSLVT.

VBIKKO = TGSBT-GTEXT.

VBELNR = BKPF-BELNR.

VSGTXT1 ='&#35531;&#27714;&#37329;&#38989;:'.

CLEAR VRECORD.

CONCATENATE VSGTXT1 BSEG-SGTXT INTO VSGTXT.

CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT

VGLT0-KSLVT VBIKKO VBELNR INTO VRECORD SEPARATED BY ','.

TRANSFER VRECORD TO E_FILE.

WRITE 😕 VPAGENO,VSUBNO,VDATAKBN,'&#35531;&#27714;&#37329;&#38989;:', VSGTXT, VGLT0-KSLVT,

VBIKKO,VBELNR.

ENDLOOP.

CLEAR: BSEG-SGTXT,GLT0-KSLVT,BKPF-BELNR.

LOOP AT ITAB_OUTPUT_ITEMS WHERE LIFNR = ITAB_LIFNR-LIFNR

AND DTYPE = 6. " &#21306;&#20998;&#65306;6

BSEG-SGTXT = ITAB_OUTPUT_ITEMS-SGTXT. " &#26126;&#32048;&#12486;&#12461;&#12473;&#12488;

IF ITAB_OUTPUT_ITEMS-SHKZG = CNS_CREDIT. " &#37329;&#38989;

GLT0-KSLVT = ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO.

ELSEIF ITAB_OUTPUT_ITEMS-SHKZG = CNS_DEBIT.

GLT0-KSLVT = ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO * -1.

ENDIF.

TGSBT-GTEXT = ITAB_OUTPUT_ITEMS-GTEXT. " &#20107;&#26989;&#38936;&#22495;&#12486;&#12461;&#12473;&#12488;

BKPF-BELNR = ITAB_OUTPUT_ITEMS-BELNR. " &#20253;&#31080;&#30058;&#21495;

SUBNO = SUBNO + 1.

VSUBNO = SUBNO.

DATAKBN = 3.

VDATAKBN = DATAKBN.

VGLT0-KSLVT = GLT0-KSLVT.

VBIKKO = TGSBT-GTEXT.

VBELNR = BKPF-BELNR.

VSGTXT1 ='&#30456;&#27578;&#37329;&#38989;:'.

CLEAR VRECORD.

CONCATENATE VSGTXT1 BSEG-SGTXT INTO VSGTXT.

CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT

VGLT0-KSLVT VBIKKO VBELNR INTO VRECORD SEPARATED BY ','.

TRANSFER VRECORD TO E_FILE.

  • concatenate vpageno vsubno vdatakbn

WRITE 😕 PAGENO,SUBNO,DATAKBN,'&#30456;&#27578;&#37329;&#38989;',BSEG-SGTXT, GLT0-KSLVT,

TGSBT-GTEXT, BKPF-BELNR.

ENDLOOP.

CLEAR VRECORD.

-


*Insert empty line.

TRANSFER EMPTYREC TO E_FILE.

-


DATAKBN = 3.

VDATAKBN = DATAKBN.

SUBNO = SUBNO + 1.

VSUBNO = SUBNO.

VSGTXT ='&#28304;&#27849;&#37329;&#38989;'.

VDMBTR = BSID-DMBTR.

CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT

VDMBTR INTO VRECORD SEPARATED BY ','.

TRANSFER VRECORD TO E_FILE.

WRITE 😕 PAGENO, SUBNO,DATAKBN, ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,

P_PAY_T,'&#28304;&#27849;&#37329;&#38989;', BSID-DMBTR.

CLEAR: VDMBTR, VSGTXT, VRECORD.

SUBNO = SUBNO + 1.

VSUBNO = SUBNO.

VSGTXT = '&#37109;&#36865;&#26009;'.

VDMBTR = BSAD-DMBTR.

CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT

VDMBTR INTO VRECORD SEPARATED BY ','.

TRANSFER VRECORD TO E_FILE.

WRITE 😕 PAGENO, SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,

P_PAY_T,'&#37109;&#36865;&#26009;', BSAD-DMBTR.

CLEAR: VDMBTR, VSGTXT, VRECORD.

SUBNO = SUBNO + 1.

VSUBNO = SUBNO.

VSGTXT = '&#25391;&#36796;&#12415;&#25163;&#25968;&#26009;'.

VDMBTR = BSEG-DMBTR.

CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT

VDMBTR INTO VRECORD SEPARATED BY ','.

TRANSFER VRECORD TO E_FILE.

CLEAR: VDMBTR, VSGTXT, VRECORD.

WRITE 😕 PAGENO,SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,

P_PAY_T,'&#25391;&#36796;&#12415;&#25163;&#25968;&#26009;',BSEG-DMBTR.

*&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;&#12398;&#20966;&#29702;

SUBNO = SUBNO + 1.

VSUBNO = SUBNO.

VSGTXT = '&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;'.

VDMBTR = GLT0-TSL05.

CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT

VDMBTR INTO VRECORD SEPARATED BY ','.

TRANSFER VRECORD TO E_FILE.

WRITE 😕 PAGENO,SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,

P_PAY_T, '&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;',GLT0-TSL05.

  • glt0-tsl05.

ULINE.

CLEAR: VREC, VRECORD,VCODE,VNAME2,VPAYDAT,VSGTXT,VSGTXT1,VKINGAKU.

CLEAR: VBIKKO,VBELNR,VDMBTR,VGLT0-KSLVT,VGLT0-TSL01,VGLT0-TSL02.

CLEAR: VGLT0-TSL03,VGLT0-TSL04,VGLT0-TSL05,VKIN,VTEGA,VWK_PAY_AMOUNT.

ENDFORM.

0 Kudos

Hi,

I don't see anything wrong with your code. Just try this out in a separate test program.

data : line1(80) type c,
       line2(80) type c value space,
       file      type string.

file = <file name that you want>.

open dataset file for output in text mode.

line1 = sy-abcde.

do 3 times.
  transfer line1 to file.
  transfer line2 to file.
enddo.

close dataset file.

I'm on 4.7. I know you are working on 4.0, but that should not really make any difference in this case.

Regards,

Anand Mandalika.

0 Kudos

hey

i tried ur example.

i dont get emptyline.i get only line1 to be displayed.

what couldbe probl?...butin 46C its working fine anand.

ambichan.

0 Kudos

Okay.... I have never worked on a 4.0 system. Just try changing the declaration of emptyrec as follows..

data emptyrec type x value '0A'.

And let me know if it works.

Regards,

Anand Mandalika.

0 Kudos

hai thanks for your reply anand.