Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Want first 8 characters to be moved to the another variable
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Mon Jun 25, 2007 10:22 am    Post subject: Want first 8 characters to be moved to the another variable
Reply with quote

Hi,

Need help to get first 8 characters of account no. I have field ACCT-NO PIC X(19). This field contains numbers only. This fields may contain 19/17/16/14/13 characters, in my case it can be 13/14 characters. Now I want first 8 characters to be moved to the another variable which has def TEMP PIC 9(8).

How can I do? I have used reference modification & inspect for temporary solution.

Please suggest on this.

Thanks,

Sandeep
Back to top
View user's profile Send private message

tosaurabh20

New User


Joined: 08 Jun 2007
Posts: 26
Location: Noida

PostPosted: Mon Jun 25, 2007 10:31 am    Post subject: Re: Hw to get first 8 characters??
Reply with quote

Help-Me-Out wrote:
Hi,

Need help to get first 8 characters of account no. I have field ACCT-NO PIC X(19). This field contains numbers only. This fields may contain 19/17/16/14/13 characters, in my case it can be 13/14 characters. Now I want first 8 characters to be moved to the another variable which has def TEMP PIC 9(8).

How can I do? I have used reference modification & inspect for temporary solution.

Please suggest on this.

Thanks,

Sandeep


Hi Sandeep,

With reference to your question, i would like to request you to use Reference modification. Hope you have heard about it, if not then it is a technique through which you can move a substring to another varaible.

Refer some manuals you will definitely find it out. Its very common in COBOL programming. still if you are not able to find it then let me know i will help you out further.

Thanks
Saurabh
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Jun 25, 2007 12:47 pm    Post subject:
Reply with quote

If the value is normally left justified with trailing blank padding, just grab the left-most eight characters through RM or redefinition.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Mon Jun 25, 2007 6:40 pm    Post subject:
Reply with quote

If it is left justified can't you just refer to it like ACCT-NO PIC(1:8)
Back to top
View user's profile Send private message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Mon Jun 25, 2007 8:33 pm    Post subject:
Reply with quote

Hi All,
Since he mention the account Number is ACCT-NO PIC X(19) and has value of 13/14 character.then we move only 8 character better we can use ACCT-NO PIC(1:8)...
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Wed Jun 27, 2007 9:45 am    Post subject: Re: Hw to get first 8 characters??
Reply with quote

Hi,

In my req acct no contains the spaces b4 actual acct no starts.
e.g. ' 1234567890123'

In this first 6 characters ar spaces. I need only 12345678. It might happen the spaces will be less or more according to the acct no.

Thanks,
Back to top
View user's profile Send private message
marvs13th

New User


Joined: 22 Jun 2007
Posts: 5
Location: philippines

PostPosted: Wed Jun 27, 2007 1:01 pm    Post subject: updated : )
Reply with quote

my code is

01 ACCT-NO PIC X(19).
01 NEW-ACCTNO REDEFINES ACCT-NO
03 TEMP-NUMERIC PIC 9(8).
03 TEMP-ALPHA PIC X(8).


think this may work........ : )
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jun 27, 2007 2:02 pm    Post subject:
Reply with quote

Hello,

How does
Quote:
01 ACCT-NO PIC X(19).
01 NEW-ACCTNO REDEFINES ACCT-NO
03 TEMP-NUMERIC PIC 9(8).
03 TEMP-ALPHA PIC X(8).

that code deal with the "leading spaces" mentioned previously?
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Thu Jun 28, 2007 8:56 am    Post subject:
Reply with quote

Could you guys tell me if this would work in the case mentioned above??

put a perform loop for i varying from 1 to 19 times(as big as the variable size). and in each turn check if that particular value of the variable i.e x(i) in the loop is a 'space'. If it is not 'space' then use reference modification from there on.

e.g

01 i pic 99 value 1.


perform varying i from 1 by 1 until i>19

if x(i:1) not= space
move x(i:8) to y
else
continue.


where x is original variable
Back to top
View user's profile Send private message
krishnakumarramaraj

New User


Joined: 15 Nov 2005
Posts: 15
Location: chennai

PostPosted: Thu Jun 28, 2007 11:34 am    Post subject: Re: Want first 8 characters to be moved to the another varia
Reply with quote

HI,
You can do it by using UNSTRING and DELIMITED BY phrase.But the receiving field should be defined such that it can contain only 8 charcters.B'coz u need only 8 characters.Hope this may work.
Regards
Krishnakumar
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jun 28, 2007 11:35 am    Post subject:
Reply with quote

Hello,

I believe that will be close if the value is alpha-numeric, but you will have problems if it is supposed to be numeric and does not contain 8 consecutive numeric digits (a test for numeric would be needed). Also, you would not want to go thru "19" as that would go beyond the end of the field.

Once you handle any case where the value is not numeric and change the "high-water" mark, that should work.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jun 28, 2007 12:00 pm    Post subject:
Reply with quote

Hello,

UNSTRING may not give the desired result. Please post the code you would suggest to accomplish removing some variable number of possible leading spaces and retaining the 8 digit numeric value.
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Thu Jun 28, 2007 3:00 pm    Post subject:
Reply with quote

but dick, is it not right that as long as the value is not SPACES in those fields the logic would work.

We just dont want the "spaces" to be there. The problem says that there could be any number of spaces and only then does the account number start. Even if the acc number is alpha or numeric the logic should work, shouldn't it?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jun 28, 2007 6:27 pm    Post subject:
Reply with quote

Hello,

Please look at the target field definition - 03 TEMP-NUMERIC PIC 9(8).

If anything other than valid numbers are moved into the field, later problems are likely. It is better to make sure the 8 bytes after the leading space(s) really contain numbers.
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Thu Jun 28, 2007 9:50 pm    Post subject:
Reply with quote

ok. i get it. Thanks. Lets hear from OP now.
Back to top
View user's profile Send private message
krishnakumarramaraj

New User


Joined: 15 Nov 2005
Posts: 15
Location: chennai

PostPosted: Fri Jun 29, 2007 11:10 am    Post subject: Re: Want first 8 characters to be moved to the another varia
Reply with quote

Hi sandeep ,
i sent you some suggesstion related to ur problem.Here is the exact thing u try this out.

UNSTRING identifier-1(WhICH HAS 12/34/56/78/93/98...)
DELIMITED BY identifier-2(this should contain'/')
INTO ident-3 [which is an x(2)],ident-4[is an X(2)],ident-5[is an X(2)],ident-6[is an X(2)]
now this will store the first 6 characters in four identfiers from 3 to 6.
Next you have to use STRING statement to brought all the 8 characters together in to a single field.its syntax is...

STRING ident-3 DELIMITED BY SIZE
ident-4 DELIMITED BY SIZE
ident-5 DELIMITED BY SIZE
ident-6 DELIMITED BY SIZE
INTO ident-7(this should acommodate 8 characters,either x(8) or 9(8))
if ident-7 is x(8) then you can use MOVE to convert it in to neumeric i.e 9(8)

Refer cobol programming M.K.Roy (Page no ;348,349 also the example given in 351)
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Jun 29, 2007 11:23 am    Post subject:
Reply with quote

Hello,

What you have posted is nothing like the requirement posted. Please re-read the entire topic and see that the requirement is to skip zero-to-n blanks before an 8 digit number.

Your example with nn/nn/nn/nn introduces the slashes which were not mentioned in the requirement and ignores leading spaces which was the main focus of the requirement.

If anyone were to try this, how would it remove leading spaces and capture an 8-digit numeric value?
Back to top
View user's profile Send private message
Ashwin_mudikon

New User


Joined: 03 Apr 2007
Posts: 32
Location: Chennai

PostPosted: Fri Jun 29, 2007 3:40 pm    Post subject:
Reply with quote

hi,

I think this may work out.


Code:
INSPECT ACC-NO TALLYING SPC-COUNT FOR LEADING SPACES.
ADD 1 TO SPC-COUNT.
MOVE ACC-NO(SPC-COUNT:8)  TO OUT-FLD.


Regards,
Ashwin
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Jun 29, 2007 6:19 pm    Post subject:
Reply with quote

Hello,

Yes, that will move the correct 8 bytes, but it will not ensure they are numeric. . .
Back to top
View user's profile Send private message
Ashwin_mudikon

New User


Joined: 03 Apr 2007
Posts: 32
Location: Chennai

PostPosted: Fri Jun 29, 2007 6:46 pm    Post subject: Re: Want first 8 characters to be moved to the another varia
Reply with quote

The variable ACC-No is a group variable. So I think it will be considered as alphanumeric and will allow spaces.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts Remove Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us