0

My situation is as follows.

I'm reading input from a file into the following working storage field: WORKING-STORAGE SECTION.

01 WORK-FIELDS. 05 W1-INPUT. 10 TESTCASE-NUMBER PIC X(02). 10 PIC X(01). 10 TESTCASE-ID PIC X(18). 10 PIC X(01). 10 TESTCASE-CONTENT PIC X(20).

Depending on what the TESTCASE-ID contains, I have to eventually move the content of the TESTCASE-CONTENT field into either the AMOUNT-DECIMAL-FORMAT or the AMOUNT-DECIMAL-NUMBER field in the following copybook:

05 (*)AMOUNT. 10 AMOUNT-DECIMAL-FORMAT PIC S9(18) COMP-3. 10 AMOUNT-DECIMAL-NUMBER PIC S9(01) COMP-3. 10 AMOUNT-IN-XML-FORMAT PIC N(20).

I then have to do a call to another program which will process these parameters and fill the AMOUNT-IN-XML-FORMAT field.

Anyway, so my question is: What's the best way to move the content of my PIC X field into my S9 COMP-3 field?

Thanks in advance for your time!

Lena
  • 147
  • 1
  • 5
  • 15
  • 2
    Is the single digit or the 18 digits in the left side or the right side of the TESTCASE-CONTENT field? In general, you move an X field into a 9 DISPLAY field first, then move the 9 DISPLAY field to the COMP-3 field. – Gilbert Le Blanc Apr 28 '16 at 15:45
  • 1
    Yes, I do it as @GilbertLeBlanc says. Either MOVE ... TO ... a-PIC-9(18). Or you can REDEFINES it that way. You have to be sure where the 18 digits are (or the single digit) and then know that they are numeric. If that can't already be guaranteed, test the relevant part of the PIC X field (REDEFINES or as subordinate items to a group) for NUMERIC. Don't do a MOVE first and then test, as that can let some rubbish through. – Bill Woodger Apr 28 '16 at 22:25
  • Thank you both! I had to do a test first before I could do the move, but it worked. I wish I could give both of you best answer – Lena May 02 '16 at 08:30
  • What platform and/or which COBOL compiler? E.g., COBOL on IBM i has alternatives. – user2338816 May 02 '16 at 23:19
  • @Lena no problem. This time we just commented anyway, rather than writing an actual answer. – Bill Woodger May 03 '16 at 13:26

0 Answers0