Application Development and Automation 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: 
Read only

how to declare a string parameter

Former Member
0 Likes
1,367

Hi all,

I declared a parameter of type string in parameters declaration part. System giving me a error as 'deep data type "string" is not allowed'.

My requirement is to declare a parameter of type string for file name in GUI_DOWNLOAD FM. If I declare any other type its goin for a short dump. How to do it. Please give relevant code for it if possible.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,289

hi suresh,

Paramerter dont accept sting data type,

instead u can do like this,

your parameter can define with like rlgrap-filename,

then u can define one more local variable with string data type,

then u can move parameter to this local variable.

that variable u can pass to gui_downlaod..

this can solves your problem,,

regards...

seshu.

Message was edited by:

maddipatla Seshu chowdary

Message was edited by:

maddipatla Seshu chowdary

8 REPLIES 8
Read only

Former Member
0 Likes
1,290

hi suresh,

Paramerter dont accept sting data type,

instead u can do like this,

your parameter can define with like rlgrap-filename,

then u can define one more local variable with string data type,

then u can move parameter to this local variable.

that variable u can pass to gui_downlaod..

this can solves your problem,,

regards...

seshu.

Message was edited by:

maddipatla Seshu chowdary

Message was edited by:

maddipatla Seshu chowdary

Read only

0 Likes
1,289

thanks for ur reply

and one more requiremnt of mine is

how to check whether given file path is valid or not while downloading a file to local system.please give with code. if any FM's available give them with code

with regards,

suresh babu aluri

Read only

0 Likes
1,289
Instead of validating path , u can give F4 help for that

PARAMETERS:p_file LIKE rlgrap-filename.
data : v_file type string.


*Input Help for the Download Directory
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  CALL FUNCTION 'F4_FILENAME'
       EXPORTING
            program_name  = v_repid
            dynpro_number = syst-dynnr
            field_name    = 'P_FILE'
       IMPORTING
            file_name     = p_file.

v_filename = p_file.
Read only

Former Member
0 Likes
1,289

Hi,

try this:

parameters: g_filename like rlgrap-filename.

this will solve ur problem.

Jogdand M B

Read only

Former Member
0 Likes
1,289

Hi,

First declare that parameter of type rlgrap-filename,

then declare your string, and assing that value to your string.

Parameters: p_file like rlgrap-filename.

data: file_str like string.

let say you entered some value in the parameter like 'C:\abc.txt'.

now assign this value to string.

file_str = p_file.

And then use file_str in GUI_DOWNLOAD func mod.

Hope this helps.

Regards,

kumar.

Read only

former_member784222
Active Participant
0 Likes
1,289

Hi,

You can make the parameter as type RLGRAP-FILENAME.

And inside your program you can assign the parameter to 'string' variable and use in the function module.

parameters: p_file like rlgrap-filename.

data: e_file type string.

Start-of-selection.

e_file = p_file.

  • use e_file in the fm GUI_DOWNLOAD

regards,

S. Chandra Mouli.

Read only

Former Member
0 Likes
1,289

Hi,

*-- Data for fieldname in search function

DATA: V_FILE LIKE DYNPREAD-FIELDNAME,

*-- Variable for storing path in charecter type

V_PATH TYPE STRING.

----


  • S E L E C T I O N S C R E E N *

----


PARAMETERS: PATH1 LIKE IBIPPARMS-PATH .

**-- On F4 key

AT SELECTION-SCREEN ON VALUE-REQUEST FOR PATH1.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = V_FILE

IMPORTING

FILE_NAME = PATH1.

V_PATH = PATH1.

**-- Function GUI_DOWNLOAD is used to save the data back in the

**-- flat file from the internal table

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = V_PATH

FILETYPE = 'ASC'

APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = Itab

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22.

IF SY-SUBRC <> 0.

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

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

  • ENDIF.

***do reward if usefull

Regards,

vijay

Read only

Former Member
0 Likes
1,289

Hi,

Please check, For file download,, and declaring file as parameters, all scenarios are covered,

Please go through code.Hope it work well for your requirement.

Reward all helpful answers.

Thanks.

REPORT Zxyx NO STANDARD PAGE HEADING MESSAGE-ID zf.

*Table Declarations

*

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

*

PARAMETERS : cb_box1 TYPE c AS CHECKBOX.

PARAMETERS : p_wsfile LIKE rlgrap-filename.

PARAMETERS : cb_box2 TYPE c AS CHECKBOX.

PARAMETERS : p_lpfile LIKE rlgrap-filename DEFAULT c_lpat.

*

SELECTION-SCREEN END OF BLOCK b2.

*

&----


  • INITIALIZATION

&----


INITIALIZATION.

*

&----


  • AT SELECTION-SCREEN

&----


AT SELECTION-SCREEN OUTPUT.

  • Change to Display Mode for Logical Path

PERFORM lpdisplay.

*

AT SELECTION-SCREEN.

  • Validate Input At Selection Screen

PERFORM screen_validation.

  • Authority Check

PERFORM authority_check.

  • Assist file Path for Download

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_wsfile.

PERFORM get_path.

*

&----


  • START-OF-SELECTION.

&----


START-OF-SELECTION.

  • Get all Accounting Document Details

PERFORM get_bkpf.

&----


  • END-OF-SELECTION.

&----


END-OF-SELECTION.

IF i_bkpf IS INITIAL.

MESSAGE s001(zf) WITH 'No Records Found for the Selection'(003).

ELSE.

  • Prepare Download Table

PERFORM fill_download.

  • Submit to gui_download.

IF NOT cb_box1 IS INITIAL.

PERFORM download_csv USING p_wsfile.

ENDIF.

  • Download to Logical Path.

IF NOT cb_box2 IS INITIAL.

PERFORM logicalpath_download.

ENDIF.

ENDIF.

&----


*& Form screen_validation

&----


  • At Selection Screen Validation for Inputs.

----


FORM screen_validation.

*

*Validation for company code

IF NOT p_bukrs IS INITIAL.

SELECT COUNT(*) FROM t001 WHERE bukrs = p_bukrs.

IF sy-subrc NE 0.

MESSAGE e001(zf) WITH 'Company Code(s) not found'(004).

ENDIF.

ENDIF.

*

*

ENDFORM. " screen_validation

&----


*& Form authority_check

&----


  • Authority Check

----


FORM authority_check.

*

*

ENDFORM. " authority_check

&----


*& Form get_bkpf

&----


  • Get Document Details

----


FORM get_bkpf.

*

SELECT

bukrs "Company Code

IF sy-subrc = 0.

SORT i_kna1 BY kunnr.

ENDIF.

*

ENDIF.

ENDFORM. " get_bkpf

&----


*& Form fill_download

&----


  • Prepare Download Table

----


FORM fill_download.

*

DATA : v_flag TYPE c.

*

v_taxsum = 0.

*

SORT i_bseg BY belnr buzei.

*

*

ENDFORM. " summary_build

&----


*& Form download_csv

&----


  • Download To Pipe CSV File

----


FORM download_csv USING v_p_wsfile LIKE rlgrap-filename.

*

DATA : v_time LIKE sy-uzeit,

v_date LIKE sy-datum,

v_fname TYPE string.

*

v_time = sy-uzeit.

v_date = sy-datum.

*

IF p_bukrs = '2000'.

CONCATENATE v_p_wsfile c_csg v_date v_time c_2000

'.TXT' INTO v_p_wsfile.

v_fname = v_p_wsfile.

ELSEIF p_bukrs = '3110'.

CONCATENATE v_p_wsfile c_ams v_date v_time c_2000

'.TXT' INTO v_p_wsfile.

v_fname = v_p_wsfile.

ENDIF.

*

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = v_fname

filetype = 'ASC'

TABLES

data_tab = i_csv[]

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

*

IF sy-subrc <> 0.

MESSAGE e001(zf) WITH v_fname

'Sorry, File download Unsucessful'(008).

ELSE.

MESSAGE s001(zf) WITH v_fname 'Download Sucessful'(009).

ENDIF.

*

ENDFORM. " download_csv

&----


*& Form get_path

&----


  • Get The File Path for Download.

----


FORM get_path.

  • Provide F4 Help for Download Path Selection

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

program_name = 'ZFIPDRDGCSV'

dynpro_number = sy-dynnr

field_name = p_wsfile

CHANGING

file_name = p_wsfile

EXCEPTIONS

mask_too_long = 1

OTHERS = 2.

*

IF sy-subrc <> 0.

MESSAGE s001(zf) WITH 'Given Path Unsucessful'(010).

ENDIF.

*

ENDFORM. " get_path

&----


*& Form lpdisplay

&----


  • Diaply the Logical path In NON EDIT MOde

----


FORM lpdisplay.

LOOP AT SCREEN.

IF screen-name = 'P_LPFILE'.

screen-input = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDFORM. " lpdisplay