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
 

 

Moving EBCDIC values to alphanumeric field in COBOL

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

New User


Joined: 23 Nov 2012
Posts: 4
Location: india

PostPosted: Mon Nov 26, 2012 9:57 am    Post subject: Moving EBCDIC values to alphanumeric field in COBOL
Reply with quote

Hi,

I am facing problem while moving EBCDIC values to alphanumeric field in COBOL.

Source Field
Code:
.. .2...345566777867   - EBCDIC Value
1040F17BFFFFFFFFFFFF   - HEX Value
320F2010345566777867




Destination Field

Code:
    2 ..345566777867
4444F47BFFFFFFFFFFFF
00002010345566777867


do we have any specific compile option for this, please help.

Code'd

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

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Nov 26, 2012 1:01 pm    Post subject: Reply to: Problem in moving EBCDIC values in alphnumeric fie
Reply with quote

And the problem is? And the code you have is? Including field definitions. In the Code tags, please.
Back to top
View user's profile Send private message
aman333

New User


Joined: 23 Nov 2012
Posts: 4
Location: india

PostPosted: Mon Nov 26, 2012 2:06 pm    Post subject: Reply to: Problem in moving EBCDIC values in alphnumeric fie
Reply with quote

Problem is that values of source field are getting changed. Hex values should be same for source and destination , but as you can see values are different. We are receiving input file from other system, and we have been told that values in VAR-MISC-DA will be in EBCDIC format.

Please find below code we are using for move:

Code:

 SELECT INPUT-FILE ASSIGN TO INFILE
    FILE STATUS IS INFILE-STATUS.     
   
 FD  INPUT-FILE                                         
        RECORDING MODE IS V                               
        RECORD VARYING 1 TO 4109 CHARACTERS               
        LABEL RECORDS ARE STANDARD.                       
                                                           
 01  INFILE-RECORD.                                     
        05  IN-FIXED-PORTION.                             
           10  FILLER                          PIC X(179).
           10  RSI-KEY                         PIC X(114).
           10  FILLER                          PIC X(276).
           10  VAR-FLD-CT                      PIC 999.   
        05  IN-VARIABLE-PORTION OCCURS 25 TIMES           
                                DEPENDING ON VAR-FLD-CT.   
           10  VAR-NM                          PIC X(5).   
      [b][color=red] 10  VAR-MISC-DA                     PIC X(125). [/b[/color]]       
       
    01  RSIR-RECORD.     
    COPY RSIR.   
    .
    .
    .
   
    03 LETTER-VARIABLE-SEGMENT.                           
                                                               
      05 VARIABLE-COUNT       PIC 9(03).                   
      05 VARIABLES     OCCURS 25 TIMES                     
             DEPENDING ON VARIABLE-COUNT.                 
          10 VARIABLE-NAME    PIC X(05).                   
         [b] [color=red]10 VARIABLE-DATA    PIC X(125).                  [/b]       
     .[/color]     .
       
   C0000-MAIN-PROCESS.                             
                                                       
           MOVE SPACES TO RSIR-RECORD.
       
           [b]READ INPUT-FILE INTO RSIR-RECORD   [/b]            AT END SET INPUT-EOF TO TRUE     
           END-READ.                         


After above read statement , values in VAR-MISC-DA are moved to VARIABLE-DATA, here values are getting changed. I have mentioned source and destination field values earlier. please have a look.

Thanks.



Mr Woodger asked IN CODE TAGS
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Mon Nov 26, 2012 2:30 pm    Post subject:
Reply with quote

Kindly show us the MOVE statement too
Back to top
View user's profile Send private message
aman333

New User


Joined: 23 Nov 2012
Posts: 4
Location: india

PostPosted: Mon Nov 26, 2012 3:18 pm    Post subject:
Reply with quote

Values are getting moved by

READ INPUT-FILE INTO RSIR-RECORD

INPUT-FILE values ----->>> RSIR-RECORD values

Field definitions have already shared above.

PIC values of both fields are same X(125).
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Mon Nov 26, 2012 3:25 pm    Post subject:
Reply with quote

Aman333, so far you have provided ZERO information that we can use to help you.

How does RSIR-RECORD relate to your source and destination fields in your original post? Source and destination implies a MOVE of some kind -- so why are you refusing to show us the MOVE statement?

You ARE aware, I hope, that reading variable length records the way you are, that you cannot rely upon anything after the number of occurrences your record specifies in VARIABLE-COUNT or VAR-FIELD-CT? And that there may be left over data in the buffer from a previous record -- which is one reason we recommend not using the buffers as you are in COBOL?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Nov 26, 2012 3:39 pm    Post subject: Reply to: Problem in moving EBCDIC values in alphnumeric fie
Reply with quote

Aman333,

How did you become aware of what you think is happening? You are showing values, but where did you get those values?

Which Cobol compiler are you using? Robert is correct in how ODO works prior to Enterprise Cobol, and I personally still feel it is good practice to always ensure that the ODO Object contains a logical value.

I can see nothing actually wrong with your READ INTO. This will "MOVE" chunks of data, there is nowhere that it does something to part of the data along the way.

If your values are not what you expect, you are either clobbering them in the program, or using the wrong index/subscript to reference them or otherwise have coded for this particular result to occur, even though you are unaware of it.

Start by saying where/how you got those results. Then go "backwards" through the process of everything in your program which references those things, directly, indirectly, at group or individual level, through CALLs or whatever, until you reach the READ INTO.

If you haven't found it by then, at least you have everything ready to post.
Back to top
View user's profile Send private message
aman333

New User


Joined: 23 Nov 2012
Posts: 4
Location: india

PostPosted: Mon Nov 26, 2012 3:46 pm    Post subject:
Reply with quote

I came to know about what is happening by using display statements. Displayed values of infile-records and RSIR-RECORD and got to know difference.

One thing to note here is that while I am browsing the input file , values are different and in display statement values are different. e.g

In 3.4 option file values are

.. .2...345566777867

While in display statement value is:

2 ..345566777867

dots are getting replaced by spaces as shown above.

I am not sure what more information do you guys need icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Nov 26, 2012 4:10 pm    Post subject: Reply to: Problem in moving EBCDIC values in alphnumeric fie
Reply with quote

Can you show the DISPLAY statements? Also definition and all references to the subscript/index you use for the DISPLAY (if you do).

Can you show the copybook?

With non-displayable characters, ISPF shows ".", so no mystery there.

As you have non-displayable characters, please show results of DISPLAY in HEX (as you did first). In the Code tags. Note that other formatting does not work inside the Code tags, so don't try it. Use the Preview button to see how your post will look, and correct formatting where necessary.
Back to top
View user's profile Send private message
Simone Salzmann

New User


Joined: 26 Nov 2012
Posts: 17
Location: Switzerland

PostPosted: Thu Nov 29, 2012 1:56 am    Post subject: Reply to: Problem in moving EBCDIC values in alphnumeric fie
Reply with quote

Hi, Aman

your last post looks very like as if the difference in the display in 3.4 and in COBOL is due to the fact that the record length and the block length are omitted in COBOL.
(Each uses two bytes at the beginning of the record)

That would correspond with the fact "Recording Mode V(ariable)" you showed in your second post.

This is not a bug but a feature.
COBOL handles the varying record length (and the block length) itself, you don't have to care for it in your program.
What's shows in position 5 in function 3.4 would be position 1 in COBOL.

Only thing: I haven't had a look into variable files in 3.4 for quite a while and can't be sure on the behavior of this function. Maybe somebody can confirm or deny my assumption.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Thu Nov 29, 2012 5:26 am    Post subject: Reply to: Problem in moving EBCDIC values in alphnumeric fie
Reply with quote

From the original post, which is in hex, the display starts with a four-byte unsigned packed field.

The leftmost "13" take the "record-length" (if it were that) well beyond the 4109 shown under the FD and the "IOCS" (the last two bytes of the potential RDW) are neither binary zero nor what would be expected for any record from a VBS/VS.

The silence may indicate a simple record-layout mismatch, or not accounting for the RDW between the two displays.
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
No new posts How to move a long alphanumeric data ... lind sh COBOL Programming 6 Mon Dec 05, 2016 7:51 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
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 Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm


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