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: 

Filling in the selection screen parameters based on condition

Former Member
0 Kudos
978

Hello,

I am trying to fill in default values for a parameter that is seen on the selection screen. This parameter refers to an O/P file name and needs to be filled with a default value based on the system that is being used:

For e.g: If the system ID is DV2, then the O/P file name should be
DV2\File A

if it is QA2, then the O/P file name should be
QA2\File A

I tried using IF...ELSE...ENDIF to check for sy-sysid :

IF sy-sysid = 'DV2'.

parameter: fname default '
DV2\File A'.

ELSE.

parameter: fname default '
QA2\File A'.

ENDIF.

but it gives the error "Parameter 'FNAME' has already been defined".

Is this possible? If yes, could someone please tell me how to do it?

Thanks,

Rugmani

1 ACCEPTED SOLUTION

Former Member
0 Kudos
402

what you need to do is to define your parameter once, then in the initialization event write the code to set the default for your values

so your code would be



parameters: fname like xxx.

initialization.

IF sy-sysid = 'DV2'.
 fname = '\\DV2\File A'.
ELSE.
 fname = '\\QA2\File A'.
ENDIF.


12 REPLIES 12

Former Member
0 Kudos
403

what you need to do is to define your parameter once, then in the initialization event write the code to set the default for your values

so your code would be



parameters: fname like xxx.

initialization.

IF sy-sysid = 'DV2'.
 fname = '\\DV2\File A'.
ELSE.
 fname = '\\QA2\File A'.
ENDIF.


0 Kudos
402

Thanks for your reply. However, if I use this IF..ENDIF condition in the initialization section, then it would not appear in the selection screen. Is it possible to determine this before the selection-screen is displayed.

Thanks,

Rugmani

0 Kudos
402

using initialization will make it appear on the selection screen .so no issues for you. Try it and see

0 Kudos
402

and if your file name differs just by the SID of the SAP box, then it is better to define a logical file name as Rob mentioned and use that instead of doing such hardcoding .

0 Kudos
402

try to use

at selection-screen output ....(pbo event)

0 Kudos
402

Unfortunately, it is not working...

Please find my code below and let me know if this is correct:

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-183.

PARAMETERS: p_ifile LIKE rlgrap-filename OBLIGATORY "Input File

  • DEFAULT 'F:\shared\acct\pr\sapje2000\pr_xxxje.prn', "01/06/03 Miu chg

DEFAULT 'F:\Accounting\payroll\pr\sapje2003\pr_xxxx_je.prn'.

PARAMETERS: outfile(40) LOWER CASE OBLIGATORY.

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

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN SKIP.

PARAMETERS: p_testfl DEFAULT 'X'. "Simulation mode

SELECTION-SCREEN SKIP.

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

PARAMETERS:

p_co LIKE t001-bukrs DEFAULT '10',

p_docdat LIKE sy-datum DEFAULT sy-datum,

p_postdt LIKE sy-datum DEFAULT sy-datum,

p_curren LIKE tcurc-waers DEFAULT 'USD',

p_refdoc LIKE bkpf-xblnr DEFAULT 'Week 14',

p_desc LIKE bkpf-bktxt DEFAULT 'ADP Payroll'.

SELECTION-SCREEN END OF BLOCK b2.

DATA: cnt TYPE i.

*----


  • INITIALIZATION

*----


IF sy-sysid = 'DV2'.

outfile = '
dbsapdv2\basis\flat_files\DV2\payroll'.

ELSEIF sy-sysid = 'QA2'.

outfile = '
dbsapdv2\basis\flat_files\QA2\payroll'.

ELSEIF sy-sysid = 'PR2'.

outfile = '
dbsapdv2\basis\flat_files\PR2\payroll'.

ENDIF.

Thanks,

Rugmani

0 Kudos
402

Please tell me how I can use a logical filename.

Thanks,

Rugmani

0 Kudos
402

where is your initialization command ? I see it is commented in your code

0 Kudos
402

try txn code FILE and see the option there.

else use


Initialization.

concatenate  '\\dbsapdv2\basis\flat_files\' sy-sysid '\payroll'  into outfile.
condense outfile no spaces.

there is no need to code for each system.

0 Kudos
402

Thank you MxG, the event INITIALIZATION was missing. Thank you for correcting it.

Thanks to everyone for your useful input.

Rugmani

0 Kudos
402

>

> Please tell me how I can use a logical filename.

>

> Thanks,

> Rugmani

Please see the documentation under IMG activity:

System Administration -> Cross Client Maintenance of File Names and Paths

This way you don't have to worry about which instance you are on. The logical file name takes care of it for you.

Rob

Former Member
0 Kudos
402

I think you can use logical file names for this as well.

Rob