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: 

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

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

After loading the data into internal table call the screen which contain table control and in the pbo populate the internal table into the table control internal table.

Former Member
0 Kudos

After getting the values in the ITAB,

1. In the table control,

Give F6 and in the textbox"Table/FieldName" give ur Internal table name and select the rows and drop in the table control.

2. In PBO of the screen give like this,

tc_zvaluemax is the table control name.

PROCESS BEFORE OUTPUT.

LOOP AT itab WITH CONTROL tc_zvaluemax CURSOR

tc_zvaluemax-current_line.

ENDLOOP.

If it helps u give points.

former_member188685
Active Contributor
0 Kudos

PROCESS BEFORE OUTPUT.

Hi Use the flow logic similar to the below code.

MODULE STATUS_0100.

LOOP WITH CONTROL TC1.

MODULE FILL_TABLE_CONTROL.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE CANCEL AT EXIT-COMMAND.

LOOP WITH CONTROL TC1.

module read_table_control.

ENDLOOP.

module user_command_0100.

vijay~

Former Member
0 Kudos

PROCESS BEFORE OUTPUT.

Use LOOP WITH instead of LOOP AT

MODULE STATUS_0100.

LOOP WITH CONTROL TC1.

MODULE FILL_TABLE_CONTROL.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE CANCEL AT EXIT-COMMAND.

LOOP WITH CONTROL TC1.

Read Table Control

ENDLOOP.

module user_command_0100.