Jump to content
The ibi Community has moved to a new platform: Please Sign In and choose Forgot Password to continue

Im using WF 8203 and Im developing a report in which I nee...


Ricardo Lara

Recommended Posts

Im using WF 8203 and Im developing a report in which I need to read a flat file delimited with pipes, which has a field with several employee IDs with the Division number they belong to:

|10092731 1 10203529 2 100057994 3 10758411 4|

In the master file, the field has USAGE=A200V. The values are structured in a way the DECODE function can use them, but is giving me errors.

I get the current employee ID from a global variable and I store it in an A8 variable (&EMPL_ID), and I get the Employee_Id-Division string from the flat file using a HOLD FORMAT ALPHA, and then using -READFILE so I can have it in a variable (&DVPS_DIV).

I have tried the following:

 

If I use DECODE in a -SET:

-SET &NEW_DIVISION = DECODE &EMPL_ID (&DVPS_DIV);

 

I get the following error message:

-SET &NEW_DIVISION = DECODE 10788081 (10097388 1 10069818 2 10021913 3 10165422 4 10053137 5 10161931 6 10020715 7);

ERROR AT OR NEAR LINE 146 IN PROCEDURE rpt_usto_targets_settingFOCEXEC *

(FOC351) INPUT FILE NOT ALLOCATED: &DVPS_DIV

 

If I use DECODE inside a TABLE FILE trying to store the Employee ID to a field in the DEFINE and the variable for the results:

DEFINE FILE ff_usto_targets_security

EMPLOYEE/A8 = 10788081 ;

END

TABLE FILE ff_usto_targets_security

PRINT

COMPUTE NEW_DIVISION/A1 = DECODE EMPLOYEE(10097388 1 10069818 2 10021913 3 10165422 4 10053137 5 10161931 6 10020715 7 ) ;

END

-RUN

0 ERROR AT OR NEAR LINE 154 IN PROCEDURE rpt_tar_settingFOCEXEC *

(FOC282) RESULT OF EXPRESSION IS NOT COMPATIBLE WITH THE FORMAT OF FIELD: EMPLOYEE

 

The error is in the DEFINE section

The funny thing is that Ive been using a lot of DECODEs in this report using -SET or inside TABLE FILEs without problems, but the difference is that I build the code-result string.

Thanks in advance.

Ricardo

Link to comment
Share on other sites

ricardo.lara:

 

-SET &NEW_DIVISION = DECODE &EMPL_ID (&DVPS_DIV);

 

 

Try replacing the above by

-SET &NEW_DIVISION = DECODE &EMPL_ID (&DVPS_DIV.EVAL ELSE '0');

or

-SET &NEW_DIVISION = DECODE &EMPL_ID.EVAL (&DVPS_DIV.EVAL ELSE '0');

Sample

-SET &FLD1 = '10165422';

-SET &FLD2 = '''10097388'' ''1'' ''10069818'' ''2'' ''10021913'' ''3'' ''10165422'' ''4'' ''10053137'' ''5'' ''10161931'' ''6'' ''10020715'' ''7''';

-SET &NEW_DIVISION = DECODE &FLD1 (&FLD2.EVAL ELSE '0');

-TYPE NEW_DIVISION: &NEW_DIVISION

Result

 

image.png111574 3.37 KB

Link to comment
Share on other sites

David / MartinY, both of your suggestions solved my problem:

- Having this string in the flat file (no quotation marks): **

- |15097388 1 60069818 2 40526913 3 32165322 4|

- MartinY -----------------------*

-SET &DVPS_DIV = TRIM_(BOTH, ', &DVPS_DIV);

-SET &NEW_DIVISION = DECODE &EMPL_ID (&DVPS_DIV.EVAL ELSE 0);

-TYPE &|NEW_DIVISION = &NEW_DIVISION

- David -------------------------------*

-SET &EMPL_ID = || &EMPL_ID || ;

DEFINE FILE ff_targets_sec

EMPLOYEE/A8 = &EMPL_ID;

END

TABLE FILE ff_targets_sec

PRINT

DUE_DATE

COMPUTE NEW_DIVISION/A1 = DECODE EMPLOYEE (&DVPS_DIV ELSE 0) ;

END

-RUN

Thanks!

Ricardo

Link to comment
Share on other sites

Easier than trying to add quotes

-SET &EMPL_ID = 10165422;

-SET &NEW_DIVISION = '''10097388'' ''1'' ''10069818'' ''2'' ''10021913'' ''3'' ''10165422'' ''4'' ''10053137'' ''5'' ''10161931'' ''6'' ''10020715'' ''7''';

 

DEFINE FILE CAR

EMPL_ID/A8 = &EMPL_ID.QUOTEDSTRING;

END

TABLE FILE CAR

PRINT EMPL_ID

COMPUTE NEW_DIVISION /A1 = DECODE EMPL_ID(&NEW_DIVISION.EVAL ELSE '0');

BY COUNTRY NOPRINT

WHERE READLIMIT EQ 1;

END

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...