IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to split a variable in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Mon Mar 24, 2008 11:07 pm
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
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: 1353
Location: Israel

PostPosted: Tue Mar 25, 2008 3:30 pm
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
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
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
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
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
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
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

Moderator Emeritus


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

PostPosted: Sun Apr 06, 2008 12:12 am
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: 2146
Location: At my coffee table

PostPosted: Sun Apr 06, 2008 12:32 am
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

Moderator Emeritus


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

PostPosted: Sun Apr 06, 2008 12:46 am
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

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Sun Apr 06, 2008 12:55 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts Compile Sp Cobol base COBOL Programming 1
Search our Forums:

Back to Top