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

Issue with gui_download function module

former_member936723
Participant
0 Likes
7,111

Hi All,

I have an issue with gui_download function module that it is creating one extra line while downloading my internal table data into text file,which i donot want.i have searched for various threads but couldnot get the proper reply.Or please provide me some other Function Module which will not create one extra line.Please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,425

Hi Ankita

Just try this and your problem will be solved.

CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      FILENAME                        = FILEPATH
     FILETYPE                        = 'ASC'
     WRITE_FIELD_SEPARATOR           = 'X'    
TABLES
      DATA_TAB                        = IT_OUTPUT

69 REPLIES 69
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,519

Hello Sas,

Mods also cant help as well. There is a limit of 2500 characters while posting the code.

BR,

Suhas

Read only

0 Likes
3,519

When you are replying post on your right side you can see some tags...

See the first one

HERE YOU PASTE THE CODE BUT REMEMBER YOU SHOULDN'T CROSS 2500 CHARACTER IF IT IS MORE CUT INTO PIECES AND PASTE

*REMOVE P AND PLACE O

EX:


  ENDIF.                               " File_Open_Error
* Log FiLE Write Start
  PERFORM 800-ILOG-WRITE.

* Processing
  CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      FILENAME         = INFILE1
      FILETYPE         = 'DAT'
    TABLES
      DATA_TAB         = T_COMM_REC1
    EXCEPTIONS
      CONVERSION_ERROR = 1
      FILE_OPEN_ERROR  = 2
      FILE_READ_ERROR  = 3
      INVALID_TYPE     = 5
      UNKNOWN_ERROR    = 7.

  IF  SY-SUBRC <> 0.
    MESSAGE I016 WITH 'Error in reading ' INFILE1.
    STOP.
  ENDIF.
*  SORT t_comm_rec1 BY w_empno.
  LOOP AT T_COMM_REC1.
    IF NOT T_COMM_REC1-W_EMPNO IS INITIAL AND
       NOT T_COMM_REC1-W_EMPNO CA '0123456789'.
      CONTINUE.
    ENDIF.

Edited by: saslove sap on Dec 9, 2009 12:05 PM

Read only

0 Likes
3,519

TABLES: PERNR,

PCL1,

PCL2,

PA0001,

PA0009,

PA0185,

T549Q, T511.

INFOTYPES: 0000,0009,0001,0008,0003, 0353.

DATA BEGIN OF EVP OCCURS 1.

INCLUDE STRUCTURE PEVPT.

DATA END OF EVP.

DATA : HIRE LIKE SY-DATUM,

FIRE LIKE SY-DATUM.

DATA : BEGIN OF ITAB1 OCCURS 0,

  • SNO TYPE N,

ENO LIKE PERNR-PERNR,

NAM LIKE P0001-ENAME,

BAC LIKE P0009-BANKN,

DEP LIKE P0001-KOSTL,

BTFR LIKE P0008-BET01 VALUE 0,

BKEY LIKE P0009-BANKL,

PDT LIKE SY-DATUM,

BETRG LIKE P0009-BETRG,

TAXID(10),

END OF ITAB1.



DATA : BEGIN OF ITCC OCCURS 0,

  • SNO TYPE N,

DEP LIKE P0001-KOSTL,

BTFR LIKE P0008-BET01 VALUE 0,

END OF ITCC.

DATA : ITCOL LIKE ITCC OCCURS 0 WITH HEADER LINE.

DATA: BERTG_TOT(16) TYPE N.

DATA : BEGIN OF ITTF OCCURS 0,

ROW(37),

END OF ITTF.

DATA : BEGIN OF IT_FAIL OCCURS 0,

EN LIKE PERNR-PERNR,

BA LIKE P0009-BANKN,

END OF IT_FAIL.


DATA : LIN TYPE I VALUE 0,
       FILE_LEN TYPE I VALUE 160,
       FILEPATH TYPE STRING,
       FR_DT LIKE SY-DATUM,
       TO_DT LIKE SY-DATUM,
       V_BAC LIKE P0009-BANKN,
       SN TYPE N VALUE 0,
       STR(37) TYPE C,
       LEN TYPE I,
       P11(11) TYPE C,
       P3(3) TYPE C,
       P13(13) TYPE N,
       P6(6) TYPE C,
       TO_P(6),
       FR_P(6),
       YEAR(4),
       MONTH(2),
       DAY(2),
       LN TYPE C.

Read only

0 Likes
3,519
DATA:BEGIN OF IT_BANK OCCURS 0,  
      EMPID(10),
      BANKN(14) TYPE N,
      BANKL(07) TYPE N,
      BETRG(10) TYPE N,
      TAXID(10),
  END OF IT_BANK.

DATA: F_NAME TYPE STRING,
      ORG_NO(07) TYPE N,
      HEADER(3),
      DATACODE(6),
      DEPT_CODE(5),
      CUST_ID(18),
      IRN(16),
      FILLER(74),
      TRANS_DAY  TYPE SY-DATUM,
      TRANS_DAY1(4) TYPE N,
      TIME TYPE SY-UZEIT,
      STR1 TYPE STRING,
      STR3 TYPE STRING,
      STR2 TYPE STRING,
      TYPE(1) TYPE C VALUE 'N',
      SEQNO(06) TYPE N,
      SEQ(08) TYPE N,
      RETURN_CODE(02) VALUE '00',
      PRES_CODE(01) VALUE 'B',
      STR7 TYPE STRING,
      COMP_CODE(06),
      PRE_DAT(08) TYPE N VALUE '00000000',
      PRE_SEQ(06) TYPE N VALUE '000000',
      PRE_CODE(01),
      STR4 TYPE STRING,
      STR5 TYPE STRING,
      STR6 TYPE STRING,

FOOTER(03) VALUE 'EOF'.
DATA:BEGIN OF IT_OUTPUT OCCURS 0,
      OUT_ROW(160) TYPE C,
     END OF IT_OUTPUT.      
DATA:BEGIN OF IT_OUTPUT_NEW OCCURS 0,
      OUT_ROW(160) TYPE C,
     END OF IT_OUTPUT_NEW.
PARAMETERS: PRD LIKE PC260-FPPER OBLIGATORY DEFAULT '200804'.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(12) TEXT-002 FOR FIELD R1.
PARAMETERS: R1 RADIOBUTTON GROUP RG1 DEFAULT 'X' USER-COMMAND RB.
SELECTION-SCREEN COMMENT 25(19) TEXT-003 FOR FIELD R2.
PARAMETERS: R2 RADIOBUTTON GROUP RG1.
SELECTION-SCREEN COMMENT 55(17) TEXT-004 FOR FIELD R3.
PARAMETERS: R3 RADIOBUTTON GROUP RG1.
SELECTION-SCREEN COMMENT 79(22) TEXT-005 FOR FIELD R4.
PARAMETERS: R4 RADIOBUTTON GROUP RG1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.


PARAMETERS: PREPBY(30) TYPE C.
PARAMETERS: APROBY(30) TYPE C.
PARAMETERS: BTC(3) TYPE C OBLIGATORY DEFAULT '014'.
PARAMETERS: FLN LIKE RLGRAP-FILENAME DEFAULT 'C:\BankTransfer'.
PARAMETERS: PY_DT LIKE PA0009-BEGDA OBLIGATORY.
PARAMETERS: ORG_AC(14) TYPE N OBLIGATORY,
            ORG_ID(10) TYPE C OBLIGATORY,
            PRS_BNK(07) TYPE N OBLIGATORY DEFAULT '0810016',
            DEPT_CD(5) TYPE C OBLIGATORY DEFAULT '00000',
            REF_NO(10) TYPE C OBLIGATORY,
            TRANS_TY(02) TYPE C OBLIGATORY,
            TRANS_ID(03) TYPE C OBLIGATORY,
            TRANS_RK(44) TYPE C OBLIGATORY.

Read only

0 Likes
3,519
INCLUDE RPPPXD00.

DATA : BEGIN OF COMMON PART A.
INCLUDE RPPPXD10.
DATA : END OF COMMON PART.

INCLUDE PC2RXTW0.

INCLUDE RPC2RX00.

DATA : BEGIN OF COMMON PART B.
INCLUDE RPC2CD00.
DATA : END OF COMMON PART.

INCLUDE RPPPXM00.
INCLUDE RPCMGR00.
AT SELECTION-SCREEN OUTPUT.
  CONCATENATE SY-DATUM+2(6) SY-UZEIT+0(4) INTO REF_NO.

  LOOP AT SCREEN.
    IF R1 = 'X'.
      IF SCREEN-NAME = 'FLN' OR SCREEN-NAME = '%_FLN_%_APP_%-TEXT' OR
         SCREEN-NAME = 'BTC'  OR SCREEN-NAME = '%_BTC_%_APP_%-TEXT' OR
        SCREEN-NAME = 'PY_DT' OR SCREEN-NAME = '%_PY_DT_%_APP_%-TEXT'
       OR SCREEN-NAME = 'ORG_ID' OR SCREEN-NAME = '%_ORG_ID_%_APP_%-TEXT'
       OR SCREEN-NAME = 'ORG_AC' OR SCREEN-NAME = '%_ORG_AC_%_APP_%-TEXT'
       OR SCREEN-NAME = 'DEPT_CD' OR SCREEN-NAME = '%_DEPT_CD_%_APP_%-TEXT'
       OR SCREEN-NAME = 'REF_NO' OR SCREEN-NAME = '%_REF_NO_%_APP_%-TEXT'
       OR SCREEN-NAME = 'PRS_BNK' OR SCREEN-NAME = '%_PRS_BNK_%_APP_%-TEXT'
       OR SCREEN-NAME = 'TRANS_TY' OR SCREEN-NAME = '%_TRANS_TY_%_APP_%-TEXT'
       OR SCREEN-NAME = 'TRANS_ID' OR SCREEN-NAME = '%_TRANS_ID_%_APP_%-TEXT'
       OR SCREEN-NAME = 'TRANS_RK' OR SCREEN-NAME = '%_TRANS_RK_%_APP_%-TEXT'.
        SCREEN-ACTIVE = 0.

      ENDIF.

ENDIF.

IF R2 = 'X'.

IF SCREEN-NAME = 'FLN' OR SCREEN-NAME = '%_FLN_%_APP_%-TEXT' OR

SCREEN-NAME = 'BTC' OR SCREEN-NAME = '%_BTC_%_APP_%-TEXT' OR

SCREEN-NAME = 'PREPBY' OR SCREEN-NAME = '%_PREPBY_%_APP_%-TEXT'

OR SCREEN-NAME = 'APROBY' OR SCREEN-NAME = '%_APROBY_%_APP_%-TEXT'

OR SCREEN-NAME = 'PY_DT' OR SCREEN-NAME = '%_PY_DT_%_APP_%-TEXT' "SOC BY ANKITA

OR SCREEN-NAME = 'ORG_ID' OR SCREEN-NAME = '%_ORG_ID_%_APP_%-TEXT'

OR SCREEN-NAME = 'ORG_AC' OR SCREEN-NAME = '%_ORG_AC_%_APP_%-TEXT'

OR SCREEN-NAME = 'DEPT_CD' OR SCREEN-NAME = '%_DEPT_CD_%_APP_%-TEXT'

OR SCREEN-NAME = 'REF_NO' OR SCREEN-NAME = '%_REF_NO_%_APP_%-TEXT'

OR SCREEN-NAME = 'PRS_BNK' OR SCREEN-NAME = '%_PRS_BNK_%_APP_%-TEXT'

OR SCREEN-NAME = 'TRANS_TY' OR SCREEN-NAME = '%_TRANS_TY_%_APP_%-TEXT'

OR SCREEN-NAME = 'TRANS_ID' OR SCREEN-NAME = '%_TRANS_ID_%_APP_%-TEXT'

OR SCREEN-NAME = 'TRANS_RK' OR SCREEN-NAME = '%_TRANS_RK_%_APP_%-TEXT'."EOC BY ANKITA

SCREEN-ACTIVE = 0.

ENDIF.

ENDIF.

Read only

0 Likes
3,519
IF R3 = 'X'.
      IF SCREEN-NAME = 'PREPBY' OR SCREEN-NAME = '%_PREPBY_%_APP_%-TEXT'
        OR SCREEN-NAME = 'APROBY' OR SCREEN-NAME = '%_APROBY_%_APP_%-TEXT'
        OR SCREEN-NAME = 'PY_DT' OR SCREEN-NAME = '%_PY_DT_%_APP_%-TEXT' 
        OR SCREEN-NAME = 'ORG_ID' OR SCREEN-NAME = '%_ORG_ID_%_APP_%-TEXT'
        OR SCREEN-NAME = 'ORG_AC' OR SCREEN-NAME = '%_ORG_AC_%_APP_%-TEXT'
        OR SCREEN-NAME = 'REF_NO' OR SCREEN-NAME = '%_REF_NO_%_APP_%-TEXT'
        OR SCREEN-NAME = 'DEPT_CD' OR SCREEN-NAME = '%_DEPT_CD_%_APP_%-TEXT'
        OR SCREEN-NAME = 'PRS_BNK' OR SCREEN-NAME = '%_PRS_BNK_%_APP_%-TEXT'
        OR SCREEN-NAME = 'TRANS_TY' OR SCREEN-NAME = '%_TRANS_TY_%_APP_%-TEXT'
        OR SCREEN-NAME = 'TRANS_ID' OR SCREEN-NAME = '%_TRANS_ID_%_APP_%-TEXT'
        OR SCREEN-NAME = 'TRANS_RK' OR SCREEN-NAME = '%_TRANS_RK_%_APP_%-TEXT'.
        SCREEN-ACTIVE = 0.
      ENDIF.
    ENDIF.
    IF R4 = 'X'.
      IF SCREEN-NAME = 'PREPBY' OR SCREEN-NAME = '%_PREPBY_%_APP_%-TEXT
         OR SCREEN-NAME = 'APROBY' OR SCREEN-NAME = '%_APROBY_%_APP_%-TEXT'
         OR SCREEN-NAME = 'BTC'  OR SCREEN-NAME = '%_BTC_%_APP_%-TEXT'.
        SCREEN-ACTIVE = 0.
      ENDIF.
    ENDIF.
    MODIFY SCREEN.

  ENDLOOP.


START-OF-SELECTION.

SELECT SINGLE * FROM T549Q WHERE PERMO = '01'

AND PABRJ = PRD+0(4)

AND PABRP = PRD+4(2).

FR_DT = T549Q-BEGDA.

TO_DT = T549Q-ENDDA.

CONCATENATE FR_DT0(4) FR_DT4(2) INTO FR_P.

CONCATENATE TO_DT0(4) TO_DT4(2) INTO TO_P.

PN-PAPER = PRD.

PN-PERMO = '01'.

GET PERNR.

RP-PROVIDE-FROM-LAST P0003 SPACE PN-BEGDA PN-ENDDA.

RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA.

IF PNP-SW-FOUND EQ 1.

  • SN = SN + 1.

  • ITAB1-SNO = SN.

  • ITCC-SNO = SN.

ITAB1-ENO = PERNR-PERNR.

ITAB1-NAM = PERNR-ENAME.

ELSE.

REJECT.

ENDIF.

RP-INIT-BUFFER.

RP-SEL-CALC.

Read only

0 Likes
3,519
CALL FUNCTION 'RP_EVALUATION_PERIODS'
    EXPORTING
      LAST_CALCULATED_DAY = P0003-ABRDT
      LAST_DAY_IN_PERIOD  = TO_DT
      RETROCALCULATED_DAY = RP-SEL-CALC-RRDAT
    TABLES
      DIR                 = RGDIR
      EVP                 = EVP
    EXCEPTIONS
      RGDIR_EMPTY         = 1
      INTERNAL_ERROR      = 2
      OTHERS              = 3.

  DESCRIBE TABLE EVP LINES LIN.
  IF LIN > 0.
    LOOP AT EVP.
      IF EVP-IAPER = TO_P AND EVP-PAPER = TO_P.
        RX-KEY-PERNR = PERNR-PERNR.
        UNPACK EVP-SEQNR TO RX-KEY-SEQNO.
        RP-IMP-C2-TN.

        READ TABLE BT INDEX 1.
        READ TABLE WPBP INDEX 1.
        READ TABLE TAX INDEX 1.
        ITAB1-BAC = BT-BANKN.
        ITAB1-BKEY = BT-BANKL .

        ITAB1-DEP = WPBP-KOSTL.
        ITAB1-BETRG = BT-BETRG.
        ITAB1-TAXID = ''.
        SELECT * FROM PA0185 WHERE  ENDDA = '99991231' AND PERNR = PERNR-PERNR AND
        ( ICTYP = '01' OR ICTYP = '02' OR ICTYP = '03' ).
          ITAB1-TAXID = PA0185-ICNUM.
        ENDSELECT.
        YEAR = VERSC-PAYDT+0(4) - 11.
        MONTH = VERSC-PAYDT+4(2).
        DAY = VERSC-PAYDT+6(2).
        CONCATENATE YEAR MONTH DAY INTO ITAB1-PDT.
       ITCC-DEP = WPBP-KOSTL.
        LOOP AT RT WHERE LGART = '/559'.
          ITAB1-BTFR = RT-BETRG.
          ITCC-BTFR = RT-BETRG.

        ENDLOOP.
      ENDIF.
    ENDLOOP.
  ENDIF.

  APPEND: ITAB1, ITCC.
  CLEAR: ITAB1, ITCC.


END-OF-SELECTION.

CONCATENATE 'Prepared By:' ` ` PREPBY INTO PREPBY.
  CONCATENATE 'Approved By:' ` ` APROBY INTO APROBY.
  IF R1 = 'X'.
    FORMAT COLOR 2.
    ULINE (127).
    NEW-LINE.
    WRITE: 2 'Sr No.', 10 'Emp Num', 27 'Name'.
    WRITE: 57 'Department'.
    WRITE: 72 '  Transfer Amount' RIGHT-JUSTIFIED.
    WRITE: 92 'Bank Key', 107 'Bank AC. Number'.
    WRITE:1 '|', 8 '|', 25 '|', 55 '|', 70 '|', 90 '|', 105 '|', 127 '|'.
    NEW-LINE.
    ULINE (127).
    NEW-LINE.
    FORMAT COLOR OFF.

    LOOP AT ITAB1.
      SN = SY-TABIX.
      WRITE: 2 SN, 10 ITAB1-ENO, 27 ITAB1-NAM.
      WRITE: 57 ITAB1-DEP.
      WRITE: 72 ITAB1-BTFR.
      WRITE: 92 ITAB1-BKEY, 107 ITAB1-BAC.
      WRITE: 1 '|', 8 '|', 25 '|', 55 '|', 70 '|', 90 '|', 105 '|', 127 '|'.
      ULINE (127).
      NEW-LINE.
    ENDLOOP.
    SKIP 4.
    ULINE 90(32).
    NEW-LINE.
    WRITE: 90 PREPBY.
    SKIP 4.
    ULINE 90(32).
    NEW-LINE.
    WRITE: 90 APROBY.
  ENDIF.

Read only

0 Likes
3,519
IF R2 = 'X'.
    LOOP AT ITCC.
      COLLECT ITCC INTO ITCOL.
    ENDLOOP.
    FORMAT COLOR 2.
    ULINE (44).
    NEW-LINE.
    WRITE:2 'Sr No.', 9 'Department'.
    WRITE: 27 'Transfer Amount  ' RIGHT-JUSTIFIED.
    WRITE:1 '|', 8 '|', 25 '|', 44 '|'.
    NEW-LINE.
    ULINE (44).
    NEW-LINE.
    FORMAT COLOR OFF.

    LOOP AT ITCOL.
      SN = SY-TABIX.
      WRITE: 2 SN, 9 ITCOL-DEP, 27 ITCOL-BTFR.
      WRITE:1 '|', 8 '|', 25 '|', 44 '|'.
      NEW-LINE.
      ULINE (44).
      NEW-LINE.
    ENDLOOP.
  ENDIF.

  IF R3 = 'X'.
    LOOP AT ITAB1.
      CLEAR: ITTF, P3, P11, P13, P6, V_BAC.
      LEN = STRLEN( ITAB1-BKEY ).
      IF LEN < 3.
        CONCATENATE ITAB1-BKEY '***' INTO P3.
      ELSE.
*       LEN = LEN - 3.
        LEN = 3.
        P3 = ITAB1-BKEY+LEN(3).
      ENDIF.
      CLEAR LEN.
      V_BAC = ITAB1-BAC.
      REPLACE ALL OCCURRENCES OF '-' IN ITAB1-BAC WITH ''.
      CONDENSE ITAB1-BAC NO-GAPS.

      LEN = STRLEN( ITAB1-BAC )."if length of acc num > limit
      IF LEN > 11.
        IT_FAIL-EN = ITAB1-ENO.
        IT_FAIL-BA = V_BAC.
        APPEND IT_FAIL.
        CLEAR: IT_FAIL.
        CONTINUE.
      ENDIF.

      P11 = ITAB1-BAC.
      CONCATENATE P11 '***********' INTO P11.
*above step is for putting '*' in place of unfilled chars of P11.

      P13 = ITAB1-BTFR * 100.
      P6 = ITAB1-PDT+2(6).

      CONCATENATE ` ` P3 P11 BTC P13 P6 INTO STR.
      ITTF-ROW = STR.
      APPEND ITTF.
    ENDLOOP.


    IF ITTF[] IS NOT INITIAL.
      CONCATENATE FLN SY-DATUM SY-UZEIT '.txt' INTO FILEPATH.
      CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                        = FILEPATH
        FILETYPE                        = 'ASC'
*      WRITE_FIELD_SEPARATOR           = 'X'
        TABLES
        DATA_TAB                        = ITTF
*      OTHERS                          = 22
        .
      SKIP 2.
      IF SY-SUBRC <> 0.
        WRITE:/ 'Unable to Download file at ', FILEPATH.
      ELSE.
        WRITE:/ 'File with following data downloaded at ', FILEPATH.
        NEW-LINE.
        SKIP 2.
        LOOP AT ITTF.
          WRITE:/ ITTF.
        ENDLOOP.
      ENDIF.
    ELSE.
      WRITE 'No Data, no file was downloaded'.
    ENDIF.
Read only

0 Likes
3,519
IF IT_FAIL[] IS NOT INITIAL.
      SKIP 2.
      FORMAT COLOR 2.
      WRITE 'Acc. No. of following employees exceeded the length limit'.
      WRITE:/ 'So their entry was not created in the file'.
      SKIP 1.
      WRITE : 'Employee Number', 20 'Bank Acc. No.'.
      FORMAT COLOR OFF.
      LOOP AT IT_FAIL.
        NEW-LINE.
        WRITE : IT_FAIL-EN, 20 IT_FAIL-BA.
      ENDLOOP.
    ENDIF.
  ENDIF.
  IF R4 = 'X'.
    WRITE:/ 'ERROR LOG - BANK A/C NO. CONTAINS ALPHANUMERIC'.
    WRITE:/ 'EMPID' COLOR COL_POSITIVE,12 '|',15 'Receiving Bank Code' COLOR COL_POSITIVE,
                                                                  40 '|','Receiver A/C No' COLOR COL_POSITIVE.
    PERFORM EXTRACT_DATA.
    SKIP 2.
  ENDIF."EOC
  RP-READ-PAYROLL-DIR.

FORM EXTRACT_DATA .

  CLEAR IT_BANK.
  REFRESH IT_BANK.

  LOOP AT ITAB1.
    REPLACE ALL OCCURRENCES OF '-' IN ITAB1-BKEY WITH SPACE.
    REPLACE ALL OCCURRENCES OF '-' IN ITAB1-BAC WITH SPACE.

    IF ITAB1-BKEY CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' OR ITAB1-BAC CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
      WRITE:/ ITAB1-ENO,12'|',15 ITAB1-BKEY,40'|', ITAB1-BAC.
      CONTINUE.
    ELSE.
      IT_BANK-BANKL = ITAB1-BKEY.
      IT_BANK-EMPID = ITAB1-ENO.
      IT_BANK-BETRG = ITAB1-BETRG.
      IT_BANK-TAXID = ITAB1-TAXID.
      SHIFT IT_BANK-TAXID LEFT DELETING LEADING SPACE.
      IT_BANK-BANKN = ITAB1-BAC.
      BERTG_TOT = BERTG_TOT + ITAB1-BETRG.
      APPEND IT_BANK.
    ENDIF.
  ENDLOOP.

HEADER = 'BOF'.
  DATACODE = 'ACHP01'.
  TRANS_DAY1 = PY_DT+0(4) - 1911.
  CONCATENATE TRANS_DAY1 PY_DT+4(2) PY_DT+6(2) INTO TRANS_DAY.
  TIME = SY-UZEIT.
  ORG_NO = ORG_AC+3(7) .
  CUST_ID = `CNHBAPGCN001417336`.
  IRN = ''.
  FILLER = ''.
  IT_OUTPUT-OUT_ROW+0(3) = HEADER.
  IT_OUTPUT-OUT_ROW+3(6) = DATACODE.
  IT_OUTPUT-OUT_ROW+9(8) = TRANS_DAY.
  IT_OUTPUT-OUT_ROW+17(6) = TIME.
  IT_OUTPUT-OUT_ROW+23(7) = ORG_NO.
  IT_OUTPUT-OUT_ROW+30(7) = PRS_BNK.
  IT_OUTPUT-OUT_ROW+37(5) = DEPT_CD.
  IT_OUTPUT-OUT_ROW+42(10) = REF_NO.
  IT_OUTPUT-OUT_ROW+52(18) = CUST_ID.
  APPEND IT_OUTPUT.
  CLEAR IT_OUTPUT.

Read only

0 Likes
3,519
LOOP AT IT_BANK.
    SEQNO = SEQNO + 1.
    IT_OUTPUT-OUT_ROW+0(1) = TYPE.
    IT_OUTPUT-OUT_ROW+1(2) = TRANS_TY.
    IT_OUTPUT-OUT_ROW+3(3) = TRANS_ID.
    IT_OUTPUT-OUT_ROW+6(6) = SEQNO.
    IT_OUTPUT-OUT_ROW+12(7) = PRS_BNK.
    IT_OUTPUT-OUT_ROW+19(14) = ORG_AC.
    IT_OUTPUT-OUT_ROW+33(7) = IT_BANK-BANKL.
    IT_OUTPUT-OUT_ROW+40(14) = IT_BANK-BANKN.
    IT_OUTPUT-OUT_ROW+54(10) = IT_BANK-BETRG.
    IT_OUTPUT-OUT_ROW+64(2)  = RETURN_CODE.
    IT_OUTPUT-OUT_ROW+66(1) = PRES_CODE.
    IT_OUTPUT-OUT_ROW+67(10) = ORG_ID.
    TRANSLATE IT_BANK-TAXID TO UPPER CASE.
    IT_OUTPUT-OUT_ROW+77(10) = IT_BANK-TAXID.
    IT_OUTPUT-OUT_ROW+87(6) = SPACE.
    IT_OUTPUT-OUT_ROW+93(8) = PRE_DAT.
    IT_OUTPUT-OUT_ROW+101(6) = PRE_SEQ.
    IT_OUTPUT-OUT_ROW+107(1) = SPACE.
    IT_OUTPUT-OUT_ROW+108(44) = TRANS_RK .
    IT_OUTPUT-OUT_ROW+152(8) = SPACE.
    APPEND IT_OUTPUT.
  ENDLOOP.
  CLEAR IT_OUTPUT.
IF IT_OUTPUT[] IS NOT INITIAL.

    CONCATENATE FLN SY-DATUM SY-UZEIT '.txt'
                                        INTO FILEPATH.


    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      FILENAME                        = FILEPATH
      FILETYPE                        = 'ASC'
*      WRITE_FIELD_SEPARATOR           = 'X'
      WK1_T_SIZE                      = FILE_LEN
      TRUNC_TRAILING_BLANKS_EOL       = ''
    TABLES
      DATA_TAB                        = IT_OUTPUT
*      OTHERS                          = 22
      .

    SKIP 2.
    IF SY-SUBRC <> 0.
      WRITE:/ 'Unable to Download file at ', FILEPATH.
    ELSE.
      WRITE:/ 'File with following data downloaded at ', FILEPATH.
      NEW-LINE.
      SKIP 2.
      LOOP AT IT_OUTPUT.
        WRITE:/ IT_OUTPUT.
      ENDLOOP.
    ENDIF.
  ELSE.
    WRITE:/ 'No Data, no file was downloaded'.
  ENDIF.
ENDFORM.

Read only

0 Likes
3,519

Hi All,

I have posted my whole code perfectly now.Please help me out now.

Read only

Former Member
0 Likes
3,519

Hi Ankita,

Case 1 :

when u pass file _len to Function module are you getting the blank line.

Ans: yes

Case 2:

When you do not pass the file-len to Function Module are you still getting the blank?

Ans:

Please answer yes or no to case 2.

Regards,

SuryaD.

Read only

0 Likes
3,519

Hi SuryaD,

Yes,when i am not giving the file-len even then the blank line is coming.

Read only

Former Member
0 Likes
3,519

Hi Ankita,

suppose your internal table is of structure as below..

itab-matnr

itab-maktx.

In the internal table at the end of every record concatenate carriage return line feed. (CL_ABAP_CHAR_UTILITIES=>CR_LF)

i.e Concatenate itab-maktx CL_ABAP_CHAR_UTILITIES=>CR_LF into itab-maktx. And modify internal table.

Just DONOT put this Carriage return for LAST ENTRY of the internal table.

Now call FM gui_download with following parameters.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = filename

filetype = 'ASC'

TRUNC_TRAILING_BLANKS = 'X'

write_lf = ' '

TABLES

data_tab = data_tab.

This will remove the blank line at the end of txt file.

Let me know if you need further help.

Read only

0 Likes
3,519

Hi Ravendra,

I am working on 4.7 and did not find CL_ABAP_CHAR_UTILITIES class in it.Please suggest some other alternative.

Thanks,

Ankita

Edited by: ANKITA BHARDWAJ on Dec 9, 2009 6:56 AM

Read only

0 Likes
3,519

Hi Ankita,

Even in 4.7 CL_ABAP_CHAR_UTILITIES class is present.

Any way you can declare two variables for carriage return and line feed and concatenate the same.

DATA: car_ret TYPE x VALUE '0D',

lin_feed TYPE x VALUE '0A'.

and Concatenate itab-maktx car_ret lin_feed INTO itab-maktx. and modify the internal table.

Remember not to concatenate car_ret and lin_feed for Last entry in internal table.

And call FM as mentioned in my previous post.

Read only

Former Member
0 Likes
6,426

Hi Ankita

Just try this and your problem will be solved.

CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      FILENAME                        = FILEPATH
     FILETYPE                        = 'ASC'
     WRITE_FIELD_SEPARATOR           = 'X'    
TABLES
      DATA_TAB                        = IT_OUTPUT

Read only

0 Likes
3,519

Hi Makan ,

I have already tried this.but the same blank line is coming.

Read only

0 Likes
3,519

Which GUI_DOWNLOAD you are having issue?

Sas

Read only

0 Likes
3,519

The Second GUI_download,where R4 = 'X'.

Read only

0 Likes
3,519

The Second GUI_download,where R4 = 'X'.

Read only

0 Likes
3,519

Hi Ankita,

Why this is happening - Because

1. Suppose we have only two lines in the internal table (1st line contains abc, 2nd line contains def),

then the output file actually contains 2 lines PLUS one extra line.

2. This extra line is not a full line.

It is an EMPTY LINE without any spaces / characters.

To say, it is a CARRIAGE LINE character inserted by GUI_DOWNLOAD.

If you open this file in notepad, and place the cursor at the last line (3rd in our case), then you won't be able to move the cursor to the right, because there are no characters as such.

3. This CARRIAGE_LINE (CR_LF) is inserted at the end of every line of the internal table, hence the problem.

4. By using some other option, (which I am trying in the mean time), if we can get rid of the last CR_LF character inside the file, then this problem will be solved. Hope this helps.

Regards,

Amit Mittal.

Read only

0 Likes
3,519

Hi Amit,

Thanks for your response.Can you guide me more on your point.

Read only

0 Likes
3,519

Hi again,

Do you want me to explain the point more clearly?

Regards,

Amit Mittal.

Read only

0 Likes
3,519

hi ,

ya plz explain more.

Read only

0 Likes
3,519

hi ,

ya plz explain more.

Read only

0 Likes
3,519

Hi again,

If you open the downloaded file in notepad, you will notice that the last empty line is there (as you have already mentioned)

My point is that the last empty line is REALLY EMPTY. It does not contain any spaces/character.

After opening in notepad, if you move the cursor to the last empty line, the cursor goes there.

However, after that if you try to move the cursor to the right (by right arrow key), it won't move. Since there are no further characters / spaces to move.

So, this file should not create any problems when you use it further for other purposes.

regards,

amit m.

Read only

0 Likes
3,519

Hi Amit,

Your point is correct but as the cursor is there one can type any thing in that,which my user does not want.do you have any idea to get rid of this.

Edited by: ANKITA BHARDWAJ on Dec 17, 2009 6:55 AM

Read only

0 Likes
3,519

Hi again,

1. EXACTLY as you want, can be done. But it is little tricky.

2. The raw problem here is the last character in the file. The last character in the file is called as new line character

(technically it consists of two characters, CARRIAGE , LINEFEED ) or we call it as CR_LF.

3. This newline character is applicable to all lines in the note pad, EXCEPT the last line. (as we want).

4. I tried this using GUI_DOWNLOAD and doing some debugging, and was ABLE to GET AS U REQUIRE.

5. So finally if you want it, we may have to copy the GUI_DOWNLOAD to ZGUI_DOWNLOAD and so VERY VERY SMALL modification, and it will work.

6. To get a feel of it in debugging, follow this;

a. In the source code of the include LSFESF02,

goto line 765

where you will find CALL FUNCTION 'DP_SEND_STREAM_TO_URL.

b. Put a breakpoint here.

7. Now when you run your program, the program will come here at this line.

8. At this point of time, in deubbing,

change the variable "par_bytes_transfered"

to have a value lessened by 2.

i.e. if it has current value of 100, change it to 98.

if it has current value of 56, change it to 54.

(we are reducing by two so that we do not want the last CR_LF character to be written to the file)

9. After changing the value of the variable in debugging, press F8 and continue the program.

10. Now check the file. It will be as u require.

I HAVE DONE THIS JUST NOW and it WORKS AS U REQUIRE. Please try this, if any problem/issues let me know.

Once this works in debugging, the FM can be copied and minor change can be done.

Hope this helps.

regards,

amit m.

Read only

0 Likes
3,519

Hi Amit,

Thanks a lot, i tried it and it is working.all i have to do is to copy the FM now and make the bytes less by 2. THANKS A LOT.You been a great help.