Cobol- String Modification

I am coming back  after a little hectic work. Just sitting relaxed and reading a book “How the Rich think“. I just started writing my blog post, got an idea to write strings.

The fact is in Cobol, strings is an important concept. We use it in many places, during dynamic sql queries, concatenating names, error handling etc. 

Usage 1:

01 Final_name                 pic x(8)  value “testname”.

String   “18”  Delimited by Size

    into   Final-name

End-String

In this case the initialized value will be modified . So the new name is “18stname”.

Usage 2:

String “My name is srinimf” Delimited by Size

      Into New-name

End-string

In this case, the complete string moved into a new variable

Usage 3:

01 City   pic   x(3)  value “New city”

String   City  Delimited by ‘  ‘

      Into New-city-name

End-string

In this case, only up to first space will be moved into new name.

Usage 4:

o1 ws-cnt    pic  99.

Move 1  to  ws-cnt.

String “My name is srinimf” Delimited by Size

      Into New-name

     with Pointer ws-cnt

End-String

In this case, the ws-cnt will have the number of chars (ws-cnt -1) that finally moved.

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.