MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Unstring

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Uma_reddy2000
Beginner


Joined: 21 Dec 2003
Posts: 2
Topics: 2
Location: Bangalore , India

PostPosted: Sat Jan 24, 2004 6:50 am    Post subject: Unstring Reply with quote

Hi ,

I have a requirement to Unstring a csv flat file in MVS (which is basically FTPed from Novell).

Here is the sample data (4 recs)-
70111,200303,-5962547.3,-5558445.36,-5823796.08
70112,200303,-3760923.67,-3227894.59,-3715484.07
70113,200303,-3175396.4,-2916627.3,-3291134.8
70114,200303,-3386233.83,-2660795.94,-3181292.63

Output Structure is :
FAORG PIC X(5)
WS-QTR PIC X(6)
WS-AMT-MON1 PIC S9(11)V99
WS-AMT-MON2 PIC S9(11)V99
WS-AMT-MON3 PIC S9(11)V99

I want to UNSTRIG the above data as follows to output structure -
For ex :
70111,200303,-5962547.3,-5558445.36,-5823796.08

FAORG PIC X(5) =70111
WS-QTR PIC X(6) =200303
WS-AMT-MON1 PIC S9(11)V99 =59625473}
WS-AMT-MON2 PIC S9(11)V99 =55584453O
WS-AMT-MON3 PIC S9(11)V99 =58237960Q

Note : My compiler is supporting the UNSTRIG-END-UNSTRIG verb but not the Reference modification

Please suggest the way to get this done.

Uma
_________________
Uma Maheswar Reddy,
Bangalore India
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sat Jan 24, 2004 2:28 pm    Post subject: Reply with quote

Hi Uma,

Show us the code you have attempted to solve the problem. Maybe we can provide some guidance. What problems have you encountered?

Regards, Jack.
Back to top
View user's profile Send private message
cobolQueen
Beginner


Joined: 28 Jan 2004
Posts: 1
Topics: 0
Location: Morristown, NJ

PostPosted: Wed Jan 28, 2004 6:21 pm    Post subject: Reply with quote

code the following:
Code:

UNSTRING INPUT-FIELD
  DELIMITED BY ','
    INTO FLD1
             FLD2
              FLD3
               FLD4
                FLD5
END-UNSTRING

Razz
Back to top
View user's profile Send private message AIM Address
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Wed Jan 28, 2004 8:29 pm    Post subject: Reply with quote

Hi Uma,

The problem you face is a complex one; more complex than one may think at 1st glance. Asking for someone to solve it for you is asking a lot. That
Back to top
View user's profile Send private message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Thu Jan 29, 2004 10:08 am    Post subject: Reply with quote

Try something like this in EZTREVE.It should work


Code:

  FILE FILEIN
         IN-REC            01 80  A

  W-STRING           W  80  A
    W-STR        W-STRING 1 A OCCURS 80

  W-AMT              W  11  A
  W-AMT1        W-AMT 1 A OCCURS 11
  W-IDX              W  02  N 0
  W-IDX1             W  02  N 0
  W-AMTO             W  11  A
  W-AMTO1       W-AMTO 1 A OCCURS 11

  W-SUB              W  02  N 0
  W-START-POS        W  02  N 0 VALUE 1
  W-STR-LENGTH       W  02  N 0
  W-DLM-COUNT        W  02  N 0 VALUE 0

  FILE FILEOUT FB(0 0)
       FLD1          01 12 A
       FLD2          *  12 A
       AMT1          *  12 A
       AMT2          *  12 A
       AMT3          *  12 A

  JOB INPUT(FILEIN)

   W-STRING = IN-REC

   W-SUB = 1
   DO  UNTIL W-SUB GT 80
    CASE W-STR (W-SUB)
         WHEN ','
    DISPLAY '******************:'
    DISPLAY 'THE W-SUB       IS:'  W-SUB
    DISPLAY 'THE W-START POS IS:'  W-START-POS
    DISPLAY 'THE W-END   POS IS:'  W-STR-LENGTH
    DISPLAY 'THE DLM COUNT   IS:'  W-DLM-COUNT
              W-DLM-COUNT        = W-DLM-COUNT  +  1
              W-STR-LENGTH       = W-SUB  - W-START-POS
              PERFORM MOVE-TO-FIELD
              W-START-POS        = W-SUB  + 1
              W-SUB              = W-SUB  + 1
         OTHERWISE
              W-SUB              = W-SUB  + 1
    END-CASE
   END-DO

   PUT FILEOUT
   MOVE ZERO  TO W-STR-LENGTH W-DLM-COUNT
   W-START-POS = 1

MOVE-TO-FIELD. PROC

    CASE W-DLM-COUNT
         WHEN 1
         MOVE W-STR (W-START-POS) W-STR-LENGTH TO FLD1
         WHEN 2
         MOVE W-STR (W-START-POS) W-STR-LENGTH TO FLD2
         WHEN 3
         W-AMT = ' '
         W-AMTO = ' '
         MOVE W-STR (W-START-POS) W-STR-LENGTH TO W-AMT
         PERFORM CONV-AMT
         MOVE W-AMTO TO AMT1
         WHEN 4
         W-AMT = ' '
         W-AMTO = ' '
         MOVE W-STR (W-START-POS) W-STR-LENGTH TO W-AMT
         PERFORM CONV-AMT
         MOVE W-AMTO TO AMT2
         W-START-POS        = W-SUB  + 1
         W-STR-LENGTH       = 80     - W-START-POS
         W-AMT = ' '
         W-AMTO = ' '
         MOVE W-STR (W-START-POS) W-STR-LENGTH TO W-AMT
         PERFORM CONV-AMT
         MOVE W-AMTO TO AMT3
    END-CASE

END-PROC
**
CONV-AMT. PROC
*
IF W-AMT1(11) SPACES
   W-AMT1(11) = '0'
END-IF
IF W-AMT1(1) EQ '-'
   W-AMT1(1) EQ ' '
   IF W-AMT1(11) = '0'
      W-AMT1(11) = '}'
   END-IF
   IF W-AMT1(11) = '1'
      W-AMT1(11) = 'J'
   END-IF
   IF W-AMT1(11) = '2'
      W-AMT1(11) = 'K'
   END-IF
   IF W-AMT1(11) = '3'
      W-AMT1(11) = 'L'
   END-IF
   IF W-AMT1(11) = '4'
      W-AMT1(11) = 'M'
   END-IF
   IF W-AMT1(11) = '5'
      W-AMT1(11) = 'N'
   END-IF
   IF W-AMT1(11) = '6'
      W-AMT1(11) = 'O'
   END-IF
   IF W-AMT1(11) = '7'
      W-AMT1(11) = 'P'
   END-IF
   IF W-AMT1(11) = '8'
      W-AMT1(11) = 'Q'
   END-IF
   IF W-AMT1(11) = '9'
      W-AMT1(11) = 'R'
   END-IF
END-IF
W-IDX = 1
W-IDX1 = 1
DO WHILE W-IDX LE 11
 IF W-AMT1(W-IDX) NE ' ' '.'
    MOVE W-AMT1(W-IDX) TO W-AMTO1(W-IDX1)
    W-IDX1 = W-IDX1 + 1
 END-IF
 W-IDX = W-IDX + 1
END-DO
END-PROC

Back to top
View user's profile Send private message
neilxt
Beginner


Joined: 01 Mar 2004
Posts: 23
Topics: 1

PostPosted: Wed May 12, 2004 4:05 pm    Post subject: Reply with quote

Quote:

have a requirement to Unstring a csv flat file in MVS (which is basically FTPed from Novell).

Here is the sample data (4 recs)-
70111,200303,-5962547.3,-5558445.36,-5823796.08
70112,200303,-3760923.67,-3227894.59,-3715484.07
70113,200303,-3175396.4,-2916627.3,-3291134.8
70114,200303,-3386233.83,-2660795.94,-3181292.63


You can't realistically unstring a number directly into a numeric field.

I think your best bet is to string them into alpha fields and then use FUNCTION NUMVAL() to convert them to true numerics.
Back to top
View user's profile Send private message Send e-mail
Mike Chantrey
Intermediate


Joined: 10 Sep 2003
Posts: 234
Topics: 1
Location: Wansford

PostPosted: Thu May 13, 2004 5:46 am    Post subject: Reply with quote

Quote:

I think your best bet is to string them into alpha fields and then use FUNCTION NUMVAL() to convert them to true numerics.


I don't think that's an option. The orignal post says their compiler 'does not support reference modification'. Ref mod was introduced at COBOL II so this implies he is using the absolutely ancient and unsupported OS/VS COBOL. FUNCTION appears even later than ref.mod - in the first LE version of COBOL I believe (?COBOL/370).

Still, it would be a fun programming excercise for the poster to write the equivalent of FUNCTION NUMVAL in OS/VS COBOL. Mr. Green
Back to top
View user's profile Send private message
neilxt
Beginner


Joined: 01 Mar 2004
Posts: 23
Topics: 1

PostPosted: Thu May 13, 2004 8:52 am    Post subject: Reply with quote

Quote:

I don't think that's an option. The orignal post says their compiler 'does not support reference modification'. Ref mod was introduced at COBOL II so this implies he is using the absolutely ancient and unsupported OS/VS COBOL. FUNCTION appears even later than ref.mod - in the first LE version of COBOL I believe (?COBOL/370).

You know, you may be right. I just took that to be a specific limitation rather than a clue that it was an old compiler.
Quote:

Still, it would be a fun programming excercise for the poster to write the equivalent of FUNCTION NUMVAL in OS/VS COBOL.

True enough - and not that difficult if you are confident that your data is reliable.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group