Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Get next 5 numeric from a string of 'LOCO' of all occurences

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

Active User


Joined: 27 Feb 2008
Posts: 108
Location: india

PostPosted: Fri Apr 24, 2020 2:30 pm    Post subject: Get next 5 numeric from a string of 'LOCO' of all occurences
Reply with quote

Hi,
suppose I have a string of 40 length, and I have some occurences of 'LOCO' and I just want to get the substring of 5 digits( only numeric) next to 'LOCO' for all occurences of the string... If next to LOCO does not have numeric of 5 occurences then its not needed...
suppose I have string:
WS-DATA -- ABCDLOCO40000kakakLOCO98abcLOCO500009898
my result would be 40000+50000=90000
can it be possible ?
What will be the approach to solve this ?

1. to get the position of LOCO.
2. check whether next 5 characters are numeric
3. use referential integrity to get the next 5 numeric data
Please post if you have any good approach to resolve this...
Thanks
Back to top
View user's profile Send private message

sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 778
Location: Maryland

PostPosted: Fri Apr 24, 2020 4:40 pm    Post subject:
Reply with quote

.del.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1204
Location: Vilnius, Lithuania

PostPosted: Fri Apr 24, 2020 4:56 pm    Post subject:
Reply with quote

Stop wasting our time with homework questions! This is a forum for experts, not for the people some $uckerberg guy once called dumb effs.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8547
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 24, 2020 6:42 pm    Post subject: Reply to: Get next 5 numeric from a string of 'LOCO' of all occurences
Reply with quote

You need to proofread your posts before you hit Submit.
Quote:
3. use referential integrity to get the next 5 numeric data
Referential integrity is a database term related to the consistency of data between tables. I assume you actually meant reference modification, which actually is a COBOL term. If you actually didn't know the difference, you need to stop posting on this forum (which is for experts) and start posting on Beginners and Students Forum instead.
Back to top
View user's profile Send private message
maxsubrat

Active User


Joined: 27 Feb 2008
Posts: 108
Location: india

PostPosted: Fri Apr 24, 2020 6:56 pm    Post subject: Reply to: Get next 5 numeric from a string of 'LOCO' of all occurences
Reply with quote

Hi, I know it's a expert forum and it's not a homework question.
sorry, it's referential modification... it's typo.

I post this in expert forum, because It's not a easy one.

Anyway thanks...
I think I too wasted my time like you...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8547
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 24, 2020 7:34 pm    Post subject: Reply to: Get next 5 numeric from a string of 'LOCO' of all occurences
Reply with quote

Quote:
I post this in expert forum, because It's not a easy one.
Well, you might THINK it's not an easy one … I figure about half a day of COBOL coding should get a good solution, compiled and tested.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1204
Location: Vilnius, Lithuania

PostPosted: Fri Apr 24, 2020 7:39 pm    Post subject: Re: Reply to: Get next 5 numeric from a string of 'LOCO' of all occurences
Reply with quote

Robert Sample wrote:
Quote:
I post this in expert forum, because It's not a easy one.
Well, you might THINK it's not an easy one … I figure about half a day of COBOL coding should get a good solution, compiled and tested.

Should we make that about half-an-hour?

Hell, I once coded an entire on-line application (2 CICS-BMS screens, 5 PL/I programs) before my coffee-break...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8547
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 24, 2020 8:42 pm    Post subject: Reply to: Get next 5 numeric from a string of 'LOCO' of all occurences
Reply with quote

Quote:
I post this in expert forum, because It's not a easy one.
I consider myself a competent COBOL programmer. I just coded a solution, using your sample data, in one hour -- so half a day is probably more than is needed. Code:
Code:
000800  WORKING-STORAGE SECTION.                                                 
000900  01  WS-VARS.                                                             
001000      05  WS-SOURCE               PIC X(80) VALUE                           
001100          'ABCDLOCO40000KAKAKLOCO98ABCLOCO500009898'.                       
001200      05  WS-WORK                 PIC X(80).                               
001300      05  WS-TEMP                 PIC X(80).                               
001400      05  WS-CUR-LOC              PIC S9(09) COMP-5 VALUE 1.               
001500      05  WS-LOCO-LOC             PIC S9(09) COMP-5 VALUE 1.               
001600      05  WS-NUM-LOC              PIC S9(09) COMP-5.                       
001700      05  WS-NUM-FLAG             PIC X(01).                               
001800  PROCEDURE DIVISION.                                                       
001900      DISPLAY 'SOURCE: ' WS-SOURCE.                                         
002000      MOVE WS-SOURCE              TO  WS-WORK.                             
002100      PERFORM 1000-PROCESS                                                 
002200          UNTIL WS-LOCO-LOC = ZERO.                                         
002300                                                                           
002400      STOP RUN.                                                             
002500                                                                           
002600  1000-PROCESS.                                                             
002700      MOVE ZERO                   TO  WS-LOCO-LOC.                         
002800      INSPECT WS-WORK                                                       
002900          TALLYING WS-LOCO-LOC                                             
003000              FOR CHARACTERS BEFORE 'LOCO' .                               
003100      COMPUTE WS-CUR-LOC = WS-LOCO-LOC + 5.                                 
003200      MOVE 'Y'                    TO  WS-NUM-FLAG.                         
003300      PERFORM                                                               
003400          VARYING WS-NUM-LOC                                               
003500              FROM WS-CUR-LOC BY 1                                         
003600              UNTIL WS-NUM-LOC > WS-CUR-LOC + 4                             
003700              IF  WS-WORK   (WS-NUM-LOC : 1) >= 0                           
003800              AND WS-WORK   (WS-NUM-LOC : 1) <= 9                           
003900                  CONTINUE                                                 
004000              ELSE                                                         
004100                  MOVE 'N'        TO  WS-NUM-FLAG                           
004200              END-IF                                                       
004300      END-PERFORM.                                                         
004400      DISPLAY 'STRING:   ' WS-WORK (1 : WS-NUM-LOC).                       
004500      DISPLAY 'NUMERIC:  ' WS-NUM-FLAG.                                     
004600      MOVE WS-WORK (WS-NUM-LOC : ) TO  WS-TEMP.                             
004700      MOVE WS-TEMP                 TO  WS-WORK.                             
yields results of
Code:
SOURCE: ABCDLOCO40000KAKAKLOCO98ABCLOCO500009898   
STRING:   ABCDLOCO40000K                           
NUMERIC:  Y                                       
STRING:   KAKAKLOCO98ABCL                         
NUMERIC:  N                                       
STRING:   LOCO500009                               
NUMERIC:  Y                                       
Perhaps you need a better understanding of what "an easy one" actually is? Based on what you've shown on this thread, you really should be posting on Beginners and Students Forumn because it doesn't matter how many "years" of industry experience you claim, you're still a beginner.
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 convert Hex String t char hex Martylin PL/I & Assembler 4 Fri Jun 05, 2020 7:45 pm
No new posts SCO 7 in numeric value gpnavinkumar COBOL Programming 7 Tue Apr 07, 2020 7:48 pm
No new posts Finding a string and concatinating mu... ArunkumarGanesan DFSORT/ICETOOL 11 Thu Jan 09, 2020 5:59 pm
No new posts String to ASCII conversion JPLMARTINS COBOL Programming 4 Sun Sep 29, 2019 12:00 am
No new posts Convert string to packed format ajaydwivedi4u COBOL Programming 6 Sat Sep 21, 2019 5:01 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us