Skip to Content
0
Former Member
Nov 24, 2005 at 05:25 AM

Upload a file from local network and loading the details in the table contr

27 Views

Hi ,

I got a problem in sap module pool programming, as i am uploading a file in an internal table and after getting the details in the internal table i want to update in the table control all the file contents to be updated in the table control of next screen,,,,,,

pls help treat this is as urgent.

code is pasted below.

FORM FCODE_LOAD.

PERFORM VALIDATE_LIST.

  • perform get_filename.

PERFORM LOAD_FILE CHANGING sy-subrc.

  • IF SY-SUBRC EQ 0.

*--- Navigate to Batch Header screen (0301)

NEXT_DYNPRO = '0301'.

  • ELSE.

  • NEXT_DYNPRO = SY-DYNNR.

  • ENDIF.

*

ENDFORM.

FORM LOAD_FILE CHANGING P_SUBRC.

DATA: LC_FILENAME LIKE RLGRAP-FILENAME.

DATA: LT_ITEMS LIKE ZVEL_ITEM_CHAR OCCURS 0 WITH HEADER LINE.

P_SUBRC = 4. " Default Failure

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

MASK = ',TextFiles,*.txt'

STATIC = 'X'

CHANGING

FILE_NAME = LC_FILENAME.

  • Ensure user selected a file name

CHECK NOT LC_FILENAME IS INITIAL.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = LC_FILENAME

FILETYPE = 'ASC'

TABLES

DATA_TAB = lt_items

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10.

P_SUBRC = SY-SUBRC.

case sy-subrc.

when '1'.

MESSAGE E918(ZU) WITH 'CONVERSION_ERROR'.

when '2'.

MESSAGE E919(ZU) WITH 'FILE_OPEN_ERROR'.

when '3'.

MESSAGE E920(ZU) WITH 'FILE_READ_ERROR'.

ENDCASE.

REFRESH: GT_ITM.

LOOP AT lt_items .

CATCH SYSTEM-EXCEPTIONS CONVERSION_ERRORS = 5.

MOVE-CORRESPONDING LT_ITEMS TO GS_ITM.

ENDCATCH.

IF SY-SUBRC EQ 5.

  • message i921(zv).

ENDIF.

APPEND GS_ITM TO GT_ITM.

ENDLOOP.

IF SY-SUBRC EQ 0.

FL_DATALOSS = 'X'.

ENDIF.

ENDFORM. " LOAD_FILE