2008 Nov 06 12:36 AM
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
2008 Nov 06 12:58 AM
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.
2008 Nov 06 12:58 AM
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.
2008 Nov 06 3:12 AM
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
2008 Nov 06 3:17 AM
using initialization will make it appear on the selection screen .so no issues for you. Try it and see
2008 Nov 06 3:18 AM
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 .
2008 Nov 06 3:19 AM
2008 Nov 06 3:19 AM
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
2008 Nov 06 3:21 AM
Please tell me how I can use a logical filename.
Thanks,
Rugmani
2008 Nov 06 3:21 AM
where is your initialization command ? I see it is commented in your code
2008 Nov 06 3:24 AM
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.
2008 Nov 06 3:26 AM
Thank you MxG, the event INITIALIZATION was missing. Thank you for correcting it.
Thanks to everyone for your useful input.
Rugmani
2008 Nov 06 2:04 PM
>
> 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
2008 Nov 06 2:16 AM