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: 

Subroutine

Former Member
0 Kudos

Hi all,

Can the function module 'gui_upload' and gui_download called in a sub routine perform (form end form). Im gettin problems while getting it in the subroutine.

regards

ab

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

once try with this code.

tables : mara, makt.

types : begin of ty_mara,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

maktx like makt-maktx,

meins like mara-meins,

end of ty_mara.

data : v_file type string.

data : it_mara type table of ty_mara,

wa_mara type ty_mara.

parameters : p_file like IBIPPARMS-PATH.

at selection-screen on value-request for p_file.

CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = p_file .

start-of-selection.

perform upload.

end-of-selection.

loop at it_mara into wa_mara.

write 😕 wa_mara-matnr,

wa_mara-mbrsh,

wa_mara-mtart,

wa_mara-maktx,

wa_mara-meins.

endloop.

form upload.

move p_file to v_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

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 = it_mara

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.

endform.

5 REPLIES 5

former_member188827
Active Contributor
0 Kudos

yes dey can be called...

wats da problem?send ur code

Sm1tje
Active Contributor
0 Kudos

Yes it can...

Former Member
0 Kudos

Hi,

Yes it is possible , we can call function modules within the subroutines.But the code should be in sequence ie: execution should be perfect . u have to fetch the records from flat file and keep them in internal table and from the internal table u need to populate.

<REMOVED BY MODERATOR>

thanks & regards,

ganesh.

Edited by: Alvaro Tejada Galindo on Apr 21, 2008 6:01 PM

Former Member
0 Kudos

Hi,

once try with this code.

tables : mara, makt.

types : begin of ty_mara,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

maktx like makt-maktx,

meins like mara-meins,

end of ty_mara.

data : v_file type string.

data : it_mara type table of ty_mara,

wa_mara type ty_mara.

parameters : p_file like IBIPPARMS-PATH.

at selection-screen on value-request for p_file.

CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = p_file .

start-of-selection.

perform upload.

end-of-selection.

loop at it_mara into wa_mara.

write 😕 wa_mara-matnr,

wa_mara-mbrsh,

wa_mara-mtart,

wa_mara-maktx,

wa_mara-meins.

endloop.

form upload.

move p_file to v_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

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 = it_mara

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.

endform.

Former Member
0 Kudos

Hi,

You can write the code like this:

Declerations:

-


-


  • obtain the file from front end

satrt-of-selection

perform sub.

-


-


form sub.

call fm gui_upload.

  • Flie1 is uploaded into itab.

call fm gui_download.

  • data is downloaded from itab to file2.

endform.

refer the file on front end.

Rgds

Umakanth