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
 

 

How to split a variable in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
krishna dileep

New User


Joined: 12 Jan 2004
Posts: 3

PostPosted: Mon Mar 24, 2008 11:13 am    Post subject: How to split a variable in cobol
Reply with quote

Hi all,
Iam encountering probelm while receiving data from the online screens. My problem is...

on the online screen data is like the below format

1) 4
2) 11
3) 12
4) 40
5) 116

The user may select one or more at a time and send it to back end
suppose if a user selects 4, 11, 116,40.. the data will be send to the backend as a whole ie.. 41111640.

now my job is to split it into the existing format ie 4, 11, 116, 40 and insert them seperately into data base.

I'm trying hard to find a logic for this. but can't.

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

star_dhruv2000

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Mon Mar 24, 2008 12:35 pm    Post subject:
Reply with quote

Hi Krishna,


Quote:
The user may select one or more at a time and send it to back end


What does this means..

Your info is not clear please be specific and give more info.[/code]
Back to top
View user's profile Send private message
rakesha.hg

Active User


Joined: 21 Mar 2008
Posts: 161
Location: bangalore

PostPosted: Mon Mar 24, 2008 2:50 pm    Post subject: Reply to: How to split a variable in cobol
Reply with quote

hi krishna,

i had tried the same logic .......

i defined the receiving fields as a table with depending upon clause for each variable.
Back to top
View user's profile Send private message
krishna dileep

New User


Joined: 12 Jan 2004
Posts: 3

PostPosted: Mon Mar 24, 2008 3:03 pm    Post subject: Reply to: How to split a variable in cobol
Reply with quote

Hi
The user may select one or more choices at a time from the online screen. The choosen values will be send to back end for insertion into data base.

Thanks & regards
dileep
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Mon Mar 24, 2008 10:14 pm    Post subject:
Reply with quote

What type of "the online screen" is it? IMS, CICS, ISPF, ...
What is the Backend? Batch job, CICS, IMS, , other ...
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Mar 24, 2008 11:07 pm    Post subject: Reply to: How to split a variable in cobol
Reply with quote

In any screen/display application, ims,cics,ispf the screen/display fields
will be seen by the application program as different fields/variables

so just design a consistent convention of exchanging multiple fields between application stages

a basic approach would be to define a structured array ...
flag,data were flag and data are suitable data types for example pic x, pic 10x

where the flag will be '0' for no data, '1' for data passed

and process data according to the flag
Back to top
View user's profile Send private message
krishna dileep

New User


Joined: 12 Jan 2004
Posts: 3

PostPosted: Tue Mar 25, 2008 12:56 pm    Post subject: Reply to: How to split a variable in cobol
Reply with quote

Hi,
The front end is a java screen and the back end is db2.
From online screen, the data will be passed to kustode(a cobol-db2 program), where it will receive the data and insert that in to database.

hope Iam clear now.

Thanks & regards
dileep
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1218
Location: Israel

PostPosted: Tue Mar 25, 2008 3:30 pm    Post subject: Re: How to split a variable in cobol
Reply with quote

krishna dileep wrote:
suppose if a user selects 4, 11, 116,40.. the data will be send to the backend as a whole ie.. 41111640.


How can you know that 41111640 splits into 4, 11, 116, 40 and not 41, 11, 16 and 40 ?
Back to top
View user's profile Send private message
star_dhruv2000

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Tue Mar 25, 2008 5:22 pm    Post subject:
Reply with quote

Quote:
How can you know that 41111640 splits into 4, 11, 116, 40 and not 41, 11, 16 and 40 ?


Yup that's what I was asking is there any fixed digits for each number.
Back to top
View user's profile Send private message
pradeep_123

New User


Joined: 21 Nov 2007
Posts: 9
Location: bhubaneswar

PostPosted: Tue Mar 25, 2008 5:46 pm    Post subject: Reply to: How to split a variable in cobol
Reply with quote

you can go for split the variable. The format was
Move variable1(1:2) to variable2. so that you can move the two byte of variable1 to variable2.

i think you can also do like this.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 25, 2008 6:00 pm    Post subject: Re: Reply to: How to split a variable in cobol
Reply with quote

pradeep_123 wrote:
you can go for split the variable. The format was
Move variable1(1:2) to variable2. so that you can move the two byte of variable1 to variable2.

i think you can also do like this.


Splitting the variable into pieces is simple and there are many ways to do it. How to know where to split the variable is the problem.
Back to top
View user's profile Send private message
chandu.be

New User


Joined: 17 Jul 2006
Posts: 9
Location: Bagalore

PostPosted: Tue Mar 25, 2008 7:13 pm    Post subject: Re: Reply to: How to split a variable in cobol
Reply with quote

1)Since you don't have fixed format of the data that you are receiving from JAVA screens. Why can't you ask them in the required format i.e with the seperator ','. Based on the seperator you can do unstring and insert into database.

2)If they are not ready to send in the required format then you have to come up with some fixed length format i.e. say individual data length is 3, then your given string would become '004011116040'. And ask java screen developers to send the string in above format. Once you receive it you can use referrence modification to divide the data into individual peices.
Back to top
View user's profile Send private message
SHAILESH OZA

New User


Joined: 10 Jun 2005
Posts: 21
Location: Mumbai

PostPosted: Sat Apr 05, 2008 5:07 pm    Post subject:
Reply with quote

Let's say your input on the screen 4,11,116,40. Store this into one variable WS-STRING, Now Appy Unstring function as below

Unstring WS-STRING into A(1), A(2), A(3), A(4),A(5) delimited by ' , '

then

it is splitted and A(5) will have space or blank value.

So while merging you can merge,

String A(1),(A2),A(3),A(4),A(5) delimited by size
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 05, 2008 7:59 pm    Post subject:
Reply with quote

Hi SHAILESH OZA,

The OP said:
Quote:
.. the data will be send to the backend as a whole ie.. 41111640.

Unfortunately, there are no commas in the string that was returned (unless he misspoke).
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: Sun Apr 06, 2008 12:12 am    Post subject:
Reply with quote

Hello,

I must admit to being confused by this one - both now and when it was originally posted.

Quote:
1) 4
2) 11
3) 12
4) 40
5) 116
If those are 5 separate fields on a screen, how did they become one contiguous series of digits? I believe if there are 5 fields, it should be fairly straight-forward to STRING them into a delimited series and then UNSTRING them later. . . If they are already in 5 screen fields, why are they combned into a single, more difficult to work with, field?

It is quite possible that there is something i misunderstand. . .
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sun Apr 06, 2008 12:32 am    Post subject:
Reply with quote

This looks more like a JAVA problem, how to get the JAVA screen to present the selected data in a form that allows the backend to split out the values correctly......
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: Sun Apr 06, 2008 12:46 am    Post subject:
Reply with quote

Hello,

Even so, the java code has separate fields ant when "forwarded" i would think they could have delimiters inserted. . . icon_confused.gif Or, be force filled to fixed length. . .
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sun Apr 06, 2008 12:55 am    Post subject: Reply to: How to split a variable in cobol
Reply with quote

the last time the poster was seen alive was about 10 days ago icon_rolleyes.gif
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
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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