cancel
Showing results for 
Search instead for 
Did you mean: 

uploading the file in selection screen

Former Member
0 Kudos

Hi,

I have a requirement where I have created a 'SELECT FROM FILE' field in the selection screen.This file has 4 columns(old material,old plant,new material,new plant).These fields are already present in the selection screen.

The requirement is,when the prg is executed,the new material has to be updated with old material values.I am able to do this,by entering the values in selection screen fields(old material,old plant,new material,new plant)

How can I upload the new material values with old material,by uploading the file?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Example of gui_upload.

REPORT ZFTP .

DATA: BEGIN OF I_FILE OCCURS 0,

DATA(2000) TYPE C,

END OF I_FILE.

DATA: BEGIN OF I_FILE2 OCCURS 0,

DATA(2000) TYPE C,

END OF I_FILE2.

DATA: W_COUNT TYPE I.

PARAMETERS: P_FILEN TYPE STRING,

P_FILE2 TYPE STRING,

P_NUM(4) TYPE N..

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILEN.

PERFORM F_FILE_GET USING P_FILEN TEXT-G01.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE2.

PERFORM F_FILE_GET USING P_FILE2 TEXT-G01.

START-OF-SELECTION.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = P_FILEN

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = ' '

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

CHECK_BOM = ' '

VIRUS_SCAN_PROFILE =

NO_AUTH_CHECK = ' '

IMPORTING

FILELENGTH =

HEADER =

tables

data_tab = I_FILE

.

IF SY-SUBRC 0.

MESSAGE E024(Z1).

ENDIF.

LOOP AT I_FILE.

W_COUNT = W_COUNT + 1.

IF NOT W_COUNT > P_NUM.

MOVE I_FILE TO I_FILE2.

APPEND I_FILE2.

ENDIF.

ENDLOOP.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE =

filename = P_FILE2

FILETYPE = 'ASC'

APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

HEADER = '00'

TRUNC_TRAILING_BLANKS = ' '

WRITE_LF = 'X'

COL_SELECT = ' '

COL_SELECT_MASK = ' '

DAT_MODE = ' '

CONFIRM_OVERWRITE = ' '

NO_AUTH_CHECK = ' '

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

WRITE_BOM = ' '

TRUNC_TRAILING_BLANKS_EOL = 'X'

WK1_N_FORMAT = ' '

WK1_N_SIZE = ' '

WK1_T_FORMAT = ' '

WK1_T_SIZE = ' '

IMPORTING

FILELENGTH =

tables

data_tab = I_FILE2

FIELDNAMES =

.

&----


*& Form F_FILE_GET

&----


text

-


-->P_P_FILEN text

-->P_TEXT_G01 text

-


FORM F_FILE_GET USING L_FILENA L_TEXT.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_FILENAME = ' '

DEF_PATH = ' '

MASK = ',.,*.TXT.'

MODE = 'O'

TITLE = L_TEXT

IMPORTING

FILENAME = L_FILENA

rc =

EXCEPTIONS

INV_WINSYS = 1

NO_BATCH = 2

SELECTION_CANCEL = 3

SELECTION_ERROR = 4

OTHERS = 5

.

IF SY-SUBRC 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Reward points if helpful.

Former Member
0 Kudos

try FM f4_filename

& gui_upload

reward if helpful

Former Member
0 Kudos

Hi,

I am able to upload the file,but how can i update the new material with the values given in the file?

Regards,

Hema

Former Member
0 Kudos

Hi,

after using those two FM you will get the data in the file in an internal table then u can write a bdc on MM02 to update the material with the data in that internal table

or if u want to update the material locally in ur program then u can change ur internal table by looping on the table containing file data and modifying ur internal table

reward if helpful else provide some detail explanation abt the requirement

regards ,

Paliwal

Former Member
0 Kudos

Hi,

I have used the FM 'KD_GET_FILENAME_ON_F4' to get the file name.Could you please give me an example for using FM 'GUI_UPLOAD'.This FM is used to upload the data to the internal table?

Regards,

Hema

Former Member
0 Kudos

Hi hema ,

I hope you have resolved your problem till now but if not so then have look on the report below which is having the same requirement but it is updating two tansactions BGM1 & ME12 ,,,,

*Developer : Ashish Paliwal

*Date : 05/02/2008

*Report : BDC on Transaction BGM1 & Transaction ME12

*Transaction Code :

*Description : BDC report on transaction BGM1 to internally generate

  • master warrnty number and then BDC on ME12 to update

  • info record by entering generated master warranty no.

  • in field Vend. mat.group. The input flat file will have

  • Vendor no & Material No.

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

  • types Declaration *

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

types: begin of t_tab1 ,

vendor(10),

material(18),

pur_org(4),

wglif(18),

end of t_tab1.

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

  • Data Declaration *

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

data : begin of it_tab5 occurs 0,

vendor(10),

material(18),

end of it_tab5.

**DATA : BEGIN OF IT_TAB6 OCCURS 0,

    • VENDOR(10),

    • MATERIAL(18),

    • END OF IT_TAB6.

data: it_tab1 type standard table of t_tab1 with header line.

data: wa_tab1 type t_tab1.

data: wa_tab2 type t_tab1.

data: it_tab3 like bdcdata occurs 0 with header line.

data: it_tab4 like bdcdata occurs 0 with header line.

data: it_tab2 type table of bdcmsgcoll with header line.

data: d_file_name like ibipparms-path,

d_file_name1 type string.

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

  • Start-of-selection *

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

start-of-selection.

        • FM for finding the flat file

call function 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

importing

file_name = d_file_name.

d_file_name1 = d_file_name.

******FM for uploading data from flat file into internal table

call function 'GUI_UPLOAD'

exporting

filename = d_file_name1

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it_tab5

exceptions

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

others = 17.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

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

  • End-of-selection *

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

end-of-selection.

sort it_tab5 by vendor.

loop at it_tab5.

perform bdc_dynpro using 'SAPLBG00' 0101 .

perform bdc_field using 'BDC_OKCODE' '/00' .

perform bdc_dynpro using 'SAPLBG00' 1000 .

perform bdc_field using 'BDC_OKCODE' '=BUCH' .

perform bdc_field using 'BDC_SUBSCR'

'SAPLBG00 1101KOPF_1000'.

perform bdc_field using 'GBGMK-GAART' '2' .

perform bdc_field using 'GBGMK-GAERB' 'X' .

perform bdc_field using 'BDC_SUBSCR'

'SAPLBG00 1103TAB_SUB_1000'.

perform bdc_field using 'BDC_CURSOR' 'GBGMP-LSTNR(01)' .

perform bdc_field using 'GBGMP-LSTNR(01)' it_tab5-material .

call transaction 'BGM1' using it_tab3 mode 'A' messages into it_tab2.

refresh it_tab3.

wa_tab1-pur_org = 'ABCP'.

loop at it_tab2.

endloop.

perform bdc_dynpro using 'SAPMM06I' 0100 .

perform bdc_field using 'BDC_CURSOR' 'EINE-EKORG' .

perform bdc_field using 'BDC_OKCODE' '/00' .

perform bdc_field using 'EINA-LIFNR' it_tab5-vendor .

perform bdc_field using 'EINA-MATNR' it_tab5-material .

perform bdc_field using 'EINE-EKORG' wa_tab1-pur_org .

perform bdc_field using 'RM06I-NORMB' 'X' .

perform bdc_dynpro using 'SAPMM06I' 0101 .

perform bdc_field using 'BDC_CURSOR' 'EINA-WGLIF' .

perform bdc_field using 'BDC_OKCODE' '=BU' .

perform bdc_field using 'EINA-WGLIF' it_tab2-msgv1 .

call transaction 'ME12' using it_tab3 mode 'A'.

refresh it_tab3.

refresh it_tab2.

endloop.

&----


*& Form BDC_DYNPRO

&----


  • Start new screen

----


  • -->P_FNAM text

  • -->P_FVAL text

----


form bdc_dynpro using program

dynpro.

clear it_tab3.

it_tab3-program = program.

it_tab3-dynpro = dynpro.

it_tab3-dynbegin = 'X'.

append it_tab3.

endform. " BDC_DYNPRO

&----


*& Form BDC_FIELD

&----


  • Insert field

----


  • -->P_FNAM text

  • -->P_FVAL text

----


form bdc_field using fnam

fval.

clear it_tab3.

it_tab3-fnam = fnam.

it_tab3-fval = fval.

append it_tab3.

endform. " BDC_FIELD

reward if helpful

Edited by: Ashish Paliwal on Apr 2, 2008 11:34 AM