Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 6: Procedure Division


MOVE: reference modification

  • This is special purpose option and can be used to move partially selected content of sending field to the receiving field
  • In COBOL-85, it is possible to refer part of a data field by mentioning the leftmost character position and length.
  • For example, assume below data declaration

    05 BOOK-NAME PIC X(12) VALUE “IBMMAINFRAME”.

    Now below statement coded in PROCEDURE DIVISON,
    MOVE BOOK-NAME(4: 6) TO CODE-NAME
    wll transfer the value “MAINFR” to CODE-NAME. Here, BOOK-NAME(4: 6) is used to refer 6 consecutive characters staring from the position 4(from left) within BOOK-NAME
  • Basic syntax:-

    identifier (position : [length] )

  • Length is optional to specify and when omitted, all the remaining characters of the identifier will be considered for operation. For example, MOVE BOOK-NAME(4: ) TO CODE-NAME will transfer the value “MAINFRAME ” to CODE-NAME.
  • It is mandatory to have a space after the delimiter colon (:).
  • The position and length can be literal/identifier/arithmetic-expression.
  • identifier filed can be of any data type, but should have DISPLAY usage






© copyright mainframebug.com
Privacy Policy