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: 

Regarding placing the file in Application server and reading file from ther

Former Member
0 Kudos

Hi All,

I have some problem during using the CALL TRANSACTION, Actually i am uploading a XL file from the local desktop.... but i wanted to shedule this in Back ground ,but it is giving dump bcz the file is in local desktop..

for that i got to know that , we can place the file in the application server and we can read the file from there and we can process..

How we can do this ?? Can any one help me with some source code how to do and can you explain the same ..

Please its urgent...

thanks,

Suresh

2 REPLIES 2

Former Member
0 Kudos

Hi

U need to ask a little help to your basis in order to transfer the file from pc to Server SAP.

Usually there are some paths defined to place the file for BI.

The easy solution is to convert the excel file in CSV format and transfer it to SAP Server, in this way you'll be able to work on ASCII file.

Now you need to change your program in order to replace the fm to upload the file with statament OPEN DATASET/READ DATASET and CLOSE DATASET.

Probably now you're using fm like GUI_UPLOAD, this fm inserts the data into an internal table, so your program should become:

OPEN DATASET <FILE> IN TEXT MODE.

DO.
   READ DATASET <FILE> TO ITAB.
   IF SY-SUBRC <> 0. EXIT. ENDIF.
   APPEND ITAB.
ENDDO.

CLOSE DATASET <FILE>.

U can use fm TEXT_CONVERT_CSV_TO_SAP in order to transfer the data in CSV format in your internal table.

Max

Former Member
0 Kudos

Hi Kutam

For Application Server u have to give

OPEN DATASET <FILE> IN TEXT MODE.

DO.

READ DATASET <FILE> TO ITAB.

IF SY-SUBRC <> 0. EXIT. ENDIF.

APPEND ITAB.

ENDDO.

CLOSE DATASET <FILE>.

u just apply nd do this

*---- Data definition -


DATA: BEGIN OF BDCDATA OCCURS 5.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF BDCDATA.

DATA: C_TCODE LIKE BKPF-TCODE VALUE 'FB01'.

DATA BEGIN OF MESSTAB OCCURS 10.

INCLUDE STRUCTURE BDCMSGCOLL.

DATA END OF MESSTAB.

**********************************************************************

*---- Call transaction -


FORM Main_Program

REFRESH BDCDATA.

PERFORM APPEND_BDC USING 'SAPMF05A' '0100' ' ' ' '.

PERFORM APPEND_BDC USING ' ' ' ' 'BKPF-BLDAT' '09031998'.

PERFORM APPEND_BDC USING ' ' ' ' 'BDC_OKCODE' '/00'.

PERFORM APPEND_BDC USING 'SAPMF05A' '0300' ' ' ' '.

PERFORM APPEND_BDC USING ' ' ' ' 'BSEG-WRBTR' '*'.

PERFORM APPEND_BDC USING ' ' ' ' 'BDC_OKCODE' 'BU'.

CALL TRANSACTION 'FB01' USING BDCDATA MODE 'N' UPDATE 'S'.

PERFORM UPDATE_IDOC_STATUS.

ENDFORM.

**********************************************************************

*--- Call transaction with errors to BDC -


REFRESH MESSTAB.

CALL TRANSACTION C_TCODE USING BDCDATA MODE 'N' UPDATE 'S'

MESSAGES INTO MESSTAB.

RETURN_CODE = SY-SUBRC.

IF RETURN_CODE = 0.

LOOP AT MESSTAB.

IF MESSTAB-MSGTYP = 'E'.

RETURN_CODE = MESSTAB-MSGNR.

SY-MSGID = 'B1'.

SY-MSGNO = 999.

SY-MSGV1 = 'Error: Check BDC'.

ENDIF.

ENDLOOP.

ENDIF.

*--- Here we check the return code, if there was an error, we put the

  • transaction in a BDC session for the user to review and correct.

IF RETURN_CODE NE 0.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'ZW'

USER = SY-UNAME

KEEP = 'X'.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = C_TCODE

TABLES

DYNPROTAB = BDCDATA.

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

NOT_OPEN = 1

QUEUE_ERROR = 2

OTHERS = 3.

ENDIF.

**********************************************************************

*--- Append BDCDATA internal table -


FORM APPEND_BDC USING VALUE(P_PROG)

VALUE(P_SCREEN)

VALUE(P_NAM)

VALUE(P_VAL).

CLEAR BDCDATA.

IF P_PROG NE SPACE.

BDCDATA-PROGRAM = P_PROG.

BDCDATA-DYNPRO = P_SCREEN.

BDCDATA-DYNBEGIN = 'X'.

BDCDATA-FNAM = P_NAM.

BDCDATA-FVAL = P_VAL.

ELSE.

BDCDATA-FNAM = P_NAM.

BDCDATA-FVAL = P_VAL.

ENDIF.

APPEND BDCDATA.

ENDFORM.