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

Want first 8 characters to be moved to the another variable


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

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Jun 29, 2007 6:59 pm
Reply with quote

Hi HMO,

You could try something like this:
Code:

1     /                                                                 
      ******************************************************************
       WORKING-STORAGE SECTION.                                         
      ******************************************************************
                                                                       
      ******************************************************************
       01  WS-WORK-FLDS.                                               
      ******************************************************************
      *===>                                                             
           05  COMP-INFO                   PIC  X(021) VALUE SPACES.   
                                                                       
           05  WS-ACCT                     PIC  X(019) VALUE           
               '      1234567890123'.                                   
***********05  WS-ACCT                     PIC  X(019) VALUE           
***************'     12345678901234'.                                   
           05  WS-ACCT-9                   PIC  9(008) VALUE 0.         
1     /                                                                 
       PROCEDURE DIVISION.                                             
      ******************************************************************
       000-MAINLINE.                                                   
      ******************************************************************
      *===>                                                             
      *===>                                                             
      *===>                                                             
      *-----------------------------------------------------------------
           DISPLAY 'TESTPGM STARTED'                                   
           MOVE FUNCTION WHEN-COMPILED  TO COMP-INFO                   
           DISPLAY 'TESTPGM COMPILED ON '                               
                   COMP-INFO(5:2) '/'                                   
                   COMP-INFO(7:2) '/'                                   
                   COMP-INFO(1:4)                                       
                   ' AT '                                               
                   COMP-INFO(9:2)                                       
                   ':'                                                 
                   COMP-INFO(11:2)                                     
           DISPLAY ' '                                           
           EVALUATE TRUE            ALSO TRUE                   
           WHEN WS-ACCT(5:1) = ' '  ALSO WS-ACCT(6:1) NUMERIC   
                MOVE WS-ACCT(6:8)     TO WS-ACCT-9               
                DISPLAY 'ACCT-9 >'  WS-ACCT-9 '< '               
           WHEN WS-ACCT(6:1) = ' '  ALSO WS-ACCT(7:1) NUMERIC   
                MOVE WS-ACCT(7:8)     TO WS-ACCT-9               
                DISPLAY 'ACCT-9 >'  WS-ACCT-9 '< '               
           END-EVALUATE                                         
           GOBACK 
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: Fri Jun 29, 2007 8:42 pm
Reply with quote

Hello,

This
Quote:
The variable ACC-No is a group variable. So I think it will be considered as alphanumeric and will allow spaces.
does not deal with ensuring the value of the 8 bytes is a valid numeric. I'm not sure why the "group" matters.

Hi Jack (bet i shouldn't yell that at the airport),
Yup, that looks like it will do what is needed - might need a few more cases for inputs with less spaces icon_smile.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Jun 29, 2007 11:09 pm
Reply with quote

Hi Dick,

I used to work w/a guy named Gene. It was kinda funny when we passed in the hallway. icon_smile.gif
Back to top
View user's profile Send private message
krishnakumarramaraj

New User


Joined: 15 Nov 2005
Posts: 15
Location: chennai

PostPosted: Fri Jul 06, 2007 10:14 am
Reply with quote

hello,
sorry for late reply.i didnt understand what u said
Back to top
View user's profile Send private message
nagasri83

New User


Joined: 20 May 2005
Posts: 15
Location: chennai

PostPosted: Thu Jul 12, 2007 6:33 am
Reply with quote

Why don't you use INSPECT & referrence modification concepts to meet this requirement.

Inspect the variable for leading SPACES and then use RM.

INSPECT ACCT-NO TALLYING CNTR FOR LEADING SPACES.
COMPUTE CNTR = CNTR + 1.
MOVE ACCT-NO(CNTR:8) TO WS-ACCT-NO-8.

Hope this works and provides the solution.
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Mon Jul 16, 2007 2:12 pm
Reply with quote

Thanks Ashwin for solution I think this gonna work in my program. As there will not be any characters in acct field.

Thanks,


Sandeep.
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: Mon Jul 16, 2007 7:09 pm
Reply with quote

Hello,

That may work as long as the value is always 8 positions long and never contains a non-numeric other than leading spaces. If the value is entered externally, ensuring that it is numeric (not just supposed to be) can prevent later abends.
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top