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

Concatenate two variables into one


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Neelima

New User


Joined: 14 Apr 2005
Posts: 6
Location: Hyderabad

PostPosted: Tue Jun 05, 2007 9:33 pm
Reply with quote

Hi All,

I have two variables:
Variable1 -- X(35) -- Value is DEEP RED
Variable2 -- X(20) -- Value is OTHER

The output should be something like
OUT-VARIABLE -- (DEEP RED OTHER).
No extra spaces should be present at the end of the output variable.

Note: In my code, the output variable is in a array.

Neelima
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Jun 05, 2007 9:39 pm
Reply with quote

Hello,

Please post your actual code.

If your output array is fixed length, there will be something following "OTHER".

If you give a more complete description of what you need to do, we will be able to offer beter suggestions.
Back to top
View user's profile Send private message
Neelima

New User


Joined: 14 Apr 2005
Posts: 6
Location: Hyderabad

PostPosted: Tue Jun 05, 2007 10:23 pm
Reply with quote

Hi,

More details below:

01 WS-GMSATTR-INFO.
05 GMS-START-TAG PIC X(26) VALUE
'<attribute name="gmsattr">'.
05 WS-GMS-TAG-1 PIC X(09) VALUE '<![CDATA['.
05 WS-GMS-ARR-OUT.
10 WS-GMS-ITEM-ARRAY OCCURS 0 TO 99999 TIMES
DEPENDING ON WS-TOT-ITEM-REC.
15 WS-ITEM-OUT PIC X(35) VALUE SPACES.
15 WS-FILLER PIC X(01) VALUE SPACES.
05 WS-GMS-TAG-2 PIC X(03).

In the above declaration, we are passing two different values one is X(35) and the other X(20) to WS-ITEM-OUT.

When we pass the value to WS-ITEM-OUT like 'DEEP RED' the output should have only the data but not extra spaces at the end.
I guess i need to change the declaration of WS-ITEM-OUT.

Please help me on this.

Neelima
Back to top
View user's profile Send private message
rahulkolhe2003

New User


Joined: 06 Mar 2007
Posts: 12
Location: columbus

PostPosted: Tue Jun 05, 2007 10:30 pm
Reply with quote

Hi Neelima,

Is this what you want?
VARIABLE1 = 'DEEP RED '
VARIABLE2 = 'OTHER'

OUT-VARIABLE = 'DEEP RED OTHER'

You can get this with the below code.

STRING VARIABLE1 DELIMITED BY ' '
' ' DELIMITED BY SIZE
VARIABLE2 DELIMITED BY SIZE
INTO OUT-VARIABLE

comment- there are 2 spaces while delimited variable1.
Back to top
View user's profile Send private message
Neelima

New User


Joined: 14 Apr 2005
Posts: 6
Location: Hyderabad

PostPosted: Wed Jun 06, 2007 12:18 am
Reply with quote

But i have a question.
When i move OUT-VARIABLE to WS-ITEM-OUT then again, it is taking spaces. should i chnage the declaration of WS-ITEM-OUT.

Please let me know
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Jun 06, 2007 1:20 am
Reply with quote

Hello,

I don't believe this
Quote:
STRING VARIABLE1 DELIMITED BY ' '
' ' DELIMITED BY SIZE
VARIABLE2 DELIMITED BY SIZE
INTO OUT-VARIABLE
will produce the desired result.

Please post more than one example of the "input data" and the result you want when your code executes. Should WS-GMS-TAG-2 be one space after the result of combining the first 2 fields? Please show at least one "complete" output string that includes from GMS-START-TAG thru WS-GMS-TAG-2.

When you post a few sets of "input", please show them as literals and include any leading or trailing spaces that might be in VARIABLE1&2. If you post using the "Code" tab at the top of the reply panel, your post will line up and be more readable.

Also, please explain how the none thru 99999 occurs will work. Assuming one big array is built, how will it be used?

Asked slightly differently, what task will all of this support?
Back to top
View user's profile Send private message
rahulkolhe2003

New User


Joined: 06 Mar 2007
Posts: 12
Location: columbus

PostPosted: Wed Jun 06, 2007 3:00 am
Reply with quote

Hi Neelima,

I am not sure how you can get rid of extra spaces :?: You can check it by simple move statment. Output showed that extra spaces will be there.
e.g.

PGM-NAME PIC X(08) VALUE SPACES.

MOVE 'PGMN' TO PGM-NAME.
DISPLAY PGM-NAME 'RAHUL'.

OUTPUT SHOWED:
PGMN RAHUL
Back to top
View user's profile Send private message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 177
Location: Seattle, WA

PostPosted: Wed Jun 06, 2007 3:03 am
Reply with quote

Those darn professors and their tricky homework assignments! icon_lol.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Jun 06, 2007 3:40 am
Reply with quote

Hello,

Once we have a more complete problem definition, we can deal with this
Quote:
I am not sure how you can get rid of extra spaces


Until we know how the final output (not just one of the intermediate contents) should look, i'm hesitant to post a solution/recommendation.

I've done similar things in the past.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Jun 06, 2007 4:21 am
Reply with quote

I know what you are trying to do but this:
Code:

01 WS-GMSATTR-INFO.
  05 GMS-START-TAG              PIC X(26)   VALUE
                         '<attribute name="gmsattr">'.
  05 WS-GMS-TAG-1               PIC X(09) VALUE '<![CDATA['.
  05 WS-GMS-ARR-OUT.
     10 WS-GMS-ITEM-ARRAY       OCCURS 0 TO 99999 TIMES
                            DEPENDING ON WS-TOT-ITEM-REC.
        15 WS-ITEM-OUT          PIC X(35) VALUE SPACES.
        15 WS-FILLER            PIC X(01) VALUE SPACES.
  05 WS-GMS-TAG-2               PIC X(03).
Is not going to work.
First off, you have defined up to 100,00 3 byte "WS-ITEM-OUT"s, and I do not think you really want that tag to be up to 3,500,000 bytes long.
And as far as the data beyond the ODO, nothing can be defined or moved to them until the depending on object gets defined.
What you need to do is to define all fixed components and data areas for the variable data.
Move all the variable data to their locations, extra spaces and all.
Then, using a redefined array or reference modification and the "ever fun" perform loop, (and this is the fun part) "burp the baby"...Squeeze the "gas" out, starting from the front, maintaining two counters (subscripts, indexes), move to the right, skipping blanks with the first and pointing to the next available receiving field with the second.
Stop when the first reaches the length of your original structure and pass the second on as the length of your compressed data area.
A single trailing space will be in each variable data item, but if that is unacceptable, even they can be removed.
Think about it and let us know what you've come up with, we all will love to aid you.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Jun 06, 2007 4:46 am
Reply with quote

Hello,

As i mentioned, i didn't want to post code/process until the final output has been defined.

Knowing where the final result will be used will also help determine how to implement.
Back to top
View user's profile Send private message
Neelima

New User


Joined: 14 Apr 2005
Posts: 6
Location: Hyderabad

PostPosted: Wed Jun 06, 2007 7:30 am
Reply with quote

Code:
D_I   C_I   S_I   ATTR_I               SUP_I

52   6   649   VENDOR SERVICED                       SALLY HANSEN       
52   6   649   VENDOR SERVICED                       NAIL TREATMENT     
52   6   649   VENDOR SERVICED                       OTHER               
52   6   1249   GRAPE                                 BEAUTY             
52   6   1250   DEEP RED                              FITNESS             
52   6   1251   HOT PINK                              BEAUTY             
52   6   1251   HOT PINK                              LOOK BRIGHT             
52   6   1251   HOT PINK                              COOL             
52   6   1254   LIME                                  BEAUTY             
52   6   1255   HONEY                                 BEAUTY             
52   6   1256   BURNT ORANGE                          BEAUTY             
52   6   1257   WINEBERRY                             BEAUTY             
52   6   1297   BUTTER                                BEAUTY             
52   6   1673   DARK BROWN                            BEAUTY             
52   6   1674   GOLD                                  BEAUTY             
52   6   1695   CORN                                  BEAUTY             


The output xml should look like:

<update id="052060649">
<attribute name="attrib"><![CDATA[VENDOR SERVICED SALLY HANSEN NAIL TREATMENT OTHER]]></attribute>
</update>
<update id="052061249">
<attribute name="attrib"><![CDATA[GRAPE BEAUTY]]></attribute>
</update>
<update id="052061250">
<attribute name="attrib"><![CDATA[DEEP RED FITNESS]]></attribute>
</update>
<update id="052061251">
<attribute name="attrib"><![CDATA[HOT PINK BEAUTY LOOK BRIGHT COOL]]></attribute>
</update>

And so on for every distinct D_I, C_I and S_I.
Note: ATTR_I is X(35)
and SUP_I is X(20).


I guess this information is fine.
Please help em out ASAP as i have code delivery tomorrow.
Back to top
View user's profile Send private message
Neelima

New User


Joined: 14 Apr 2005
Posts: 6
Location: Hyderabad

PostPosted: Wed Jun 06, 2007 7:31 am
Reply with quote

Hi,
Someone help me asap.

Neelima
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Jun 06, 2007 8:12 am
Reply with quote

Hello,

How does this incorporate the array that occurs 0 to 99999 times?

What are the "rules" for combining info from multiple input lines?

Your initial post mentions
Quote:
we are passing two different values one is X(35) and the other X(20)
i don't see 35- and 20-byte fields in your most recent post of data. You describe them after the records, but the data does not appear to conform to that definition.

Is what you posted the "real" input data? What is the record layout of that input data?

This
Quote:
I guess this information is fine.
is somewhat overstated. . . .

A routine might know that these 3 (VENDOR SERVICED (lth15))
Code:
52 6 649 VENDOR SERVICED SALLY HANSEN
52 6 649 VENDOR SERVICED NAIL TREATMENT
52 6 649 VENDOR SERVICED OTHER
should be treated as a group, but these 3
Code:

52 6 1251 HOT PINK BEAUTY
52 6 1251 HOT PINK LOOK BRIGHT
52 6 1251 HOT PINK COOL
are also grouped in your output even though 15 characters makes them NOT a group?

I believe i see how you got from those "input" records to the sample output, but you need to describe what rules the code would have to follow to accomplish this.

If delivery of working code for this is due on Wed your local time, you might want to alert someone that the requirement definition is still being worked on.
Back to top
View user's profile Send private message
ajayvamsi

New User


Joined: 21 Jul 2005
Posts: 56
Location: Hyderabad

PostPosted: Wed Jun 06, 2007 3:16 pm
Reply with quote

I am sorry for the delay but here is the solution

var-1 35
var-2 20

take another variable of length var-3 of size 35 + 20 = 55
take another values for calculating the size of var-3

01 BLK-CTR pic 9(02) value zeroes.

MOVE VAR-1 TO VAR-3(1:35).
MOVE VAR-2 TO VAR-3(36:20).

hope u r clear till this point.

now use the below code

INSPECT FUNCTION REVERSE(var-3)
TALLYING BLK-CTR FOR LEADING SPACES

as u said that ur out-varable is in occurs with depending [suppose X]

then compute X = 55 - BLK-CTR

and now move ur var-3(1:X) to occurs variable.

Please let me know if u have any cocerns

thanks for ur good query

sorry again for delay solution

bye
ajay
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Jun 06, 2007 5:56 pm
Reply with quote

Hello,

I believe that suggestion will not create the desired output from the posted input. Please re-read the original and follow on posts and notice that the needed output requires more than simply combining strings. When there are "multiples" they must be combined into a single string.
Back to top
View user's profile Send private message
rahulkolhe2003

New User


Joined: 06 Mar 2007
Posts: 12
Location: columbus

PostPosted: Wed Jun 06, 2007 10:05 pm
Reply with quote

Hello Dick,

Quote:

Once we have a more complete problem definition, we can deal with this Quote:
I am not sure how you can get rid of extra spaces


Could you please throw some light on how we can get rid of extra spaces.

Code:
PGM-NAME PIC X(08) VALUE SPACES.

MOVE 'PGMN' TO PGM-NAME.
DISPLAY PGM-NAME 'RAHUL'.


OUTPUT SHOWED:
PGMN    RAHUL


How to display it like
Code:

PGMNRAHUL


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

Global Moderator


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

PostPosted: Wed Jun 06, 2007 10:51 pm
Reply with quote

Code:
PGM-NAME PIC X(04) VALUE SPACES.

MOVE 'PGMN' TO PGM-NAME.
DISPLAY PGM-NAME 'RAHUL'.

or
Code:
PGM-NAME PIC X(08) VALUE SPACES.

MOVE 'PGMN' TO PGM-NAME.
DISPLAY PGM-NAME(1:4) 'RAHUL'.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Jun 07, 2007 12:27 am
Reply with quote

Hello,

To get what you want, i'd suggest calculating the "good data" length of the first field and then use a reference modified STRING to combine the desired length from the first field with the data from the second field into a 3rd field. Now you have only what you want in a single field.

Code:
STRING IN-FIELD1(1:lth)
       IN-FIELD2 DELIMITED BY '~'
  INTO RESULT-FIELD.
DISPLAY RESULT-FIELD. 


The length will not be a literal, but the result of finding the last meaningful character. The display at the end should give you the requested result.
Back to top
View user's profile Send private message
Pons

New User


Joined: 25 May 2007
Posts: 61
Location: Coimbatore

PostPosted: Thu Jun 07, 2007 6:04 pm
Reply with quote

STRING VAR1 DELIMITED BY ' ' ' '
DELIMITED BY SIZE
VAR2 DELIMITED BY ' ' ' '
DELIMITED BY SIZE
INTO VAR3.

I hope it will work.
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 JCL with variables JCL & VSAM 1
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts JCL Variables JCL & VSAM 1
No new posts reset/clear ALL application profile v... TSO/ISPF 3
No new posts REXX - Adding variables CLIST & REXX 8
Search our Forums:

Back to Top