Move in cobol

Move in cobol DEFAULT

MOVE statement is used to assign a value to one or more variables from another variable or literal. MOVE statement actually transfers the data from one memory location to one or more memory locations.

In MOVE statement, sending data item should be only one. In MOVE statement, receiving data item can be more than one. The sending data item, receiving data item can be a group item or elementary item.

During the MOVE statement execution, the receiving data items data completely replaced by sending data item data. The receiving item is an elementary data item and the sending item is an elementary data item or a literal is called elementary move.

Valid operands belong to one of the following categories -

  • Alphabetic
  • Alphanumeric
  • Alphanumeric-edited
  • External floating-point
  • Internal floating-point
  • Numeric
  • Numeric-edited

Move Types -

MOVE statements are classified into below based on its usage in the program -

  1. Simple MOVE
  2. Group MOVE
  3. Corresponding MOVE
  4. MOVE Referencing Modification

Move Rules -

In some scenarios, data conversion required if the target data item data type is different. The conversion automatically takes place during the MOVE from one form of internal representation to another whenever required.

This includes along with editing in or de-editing implied by the receiving item. The following rules outline the execution of elementary moves when the receiving field is -

Alphabetic -

Alphabetic data alignment is from left to right.If the size of the sending item is less than the size of the receiving item, the receiving item is filled from left to right and the remaining positions are filled with SPACES.

If the size of the sending item is greater than the size of the receiving item, excess characters on the right are truncated after the receiving item is filled.

Alphanumeric or alphanumeric-edited -

If the sending item is a decimal integer item, the sending data is converted to usage DISPLAY and moved to a temporary data item of category alphanumeric with the same number of character positions as the sending item. The resulting alphanumeric data item is treated as the sending item.

Alphanumeric data alignment is from left to right. If the size of the sending item is less than the size of the receiving item, the receiving item is filled from left to right and the remaining positions are filled with SPACES.

If the size of the sending item is greater than the size of the receiving item, excess characters on the right are truncated after the receiving item is filled.

If the initial sending item has sign, the sign ignores and unsigned value is used. If the sign occupies a separate character, the sign character is not moved and the size of the sending item is considered one less character than the actual size.

External floating-point -

For a floating-point sending item, the floating-point value is converted to the usage of the receiving external floating-point item. For other sending items, the numeric value is converted to internal floating-point and then converted to the usage of the receiving external floating-point item.

Internal floating-point -

If the sending operand value is not internal floating-point, the value is converted to internal floating-point format.

Numeric or numeric-edited -

Numeric data alignment is from right to left.

If the receiving item is signed, the sign is placed in the receiving item with any necessary sign conversion. If the sending item is unsigned, a positive operational sign is generated for the receiving item.

If the receiving item is unsigned, no sign is generated for the receiving item and the absolute value is used in the move. When the category of the sending item is alphanumeric, alphanumeric-edited, the data is moved as an unsigned integer.

When the sending item is floating-point, the data is first converted to either a binary or internal decimal representation and then moved. When the receiving item is numeric-edited, editing takes place as defined by the picture character string or BLANK WHEN ZERO clause associated with the receiving item.

When the sending item is numeric-edited, the compiler de-edits the sending data to establish the unedited value and then unedited value is used in the move to the receiving numeric or numeric-edited data item.

Date Fields -

If the sending item is a year-last date field, then all receiving fields must also be year-last date fields with the same date format as the sending item.

If receiving item is a year-last date field, then the sending item must be either a nondate or a year-last date field with the same date format as the receiving item. In both cases, the move is performed as if all items were nondates.

If the sending item is a date field, then the receiving item must be a compatible date field. If the sending and receiving items are both date fields, then they must be compatible (that is, they must have the same date format, except for the year part).

Note-1! If the receiving item is of category alphanumeric, alphanumeric-edited or numeric-edited, the sending field is numeric and any digit positions with picture symbol P in the sending item are considered to have the value zero. Each P is counted in the size of the sending item.


Note-2! If the receiving item is numeric and the sending field is an alphanumeric literal or an ALL literal, all characters of the literal must be numeric characters.

MOVE Combinations -

The below table represents the valid and invalid moves using MOVE statement foreach category. In the table, column headings indicate receiving item categories, row headings indicate sending item categories.

Alphabetic Alpha-numeric Alpha-numeric edited Numeric Numeric edited External floating-point Internal floating-point
Alphabetic and SPACE Y Y Y N N N N
Alphanumeric Y Y Y Y Y Y Y
Alphanumeric-edited Y Y Y N N N N
Numeric integer and ZERO N Y Y Y Y Y Y
Numeric non-integer N N N Y Y Y Y
Numeric-edited N Y Y Y Y Y Y
Floating-point N N N Y Y Y Y
Sours: https://www.mainframestechhelp.com/tutorials/cobol/move-statement.htm

Move Verb in COBOL

Move Verb

  • Move verb is used for copying the data from source to destination data.
  • It is used on both elementary and group data items.
  • MOVE CORRESPONDING/CORR is used for group data items.
  • MOVE CORR may not work on some online tools but it will work on a mainframe server.
  • MOVE(x:l) is used for moving the data from a string. Where, x is the starting position and l is length.
  • If the destination data item PIC clause is less than the source data item PIC clause then data will be cut or truncated.
  • ZEROs or SPACEs will be added for extra bytes if the destination data item PIC clause is larger than the PIC clause of source data item.

Example : Demonstration of MOVE verb

IDENTIFICATION DIVISION.
PROGRAM-ID. MV.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-N1 PIC 9(8).
   01 WS-N2 PIC 9(8).
   01 WS-N3 PIC 9(5).
   01 WS-N4 PIC 9(4).
   01 WS-EMP-ADDRESS.
   05 WS-EMP-HOUSE-NUMBER PIC 9(3).
   05 WS-EMP-STATE PIC X(11).
   05 WS-EMP-PIN PIC 9(6).
   01 WS-STUDENT-ADDRESS.
   05 WS-STUD-HOUSE-NUMBER PIC 9(3).
   05 WS-STUD-STATE PIC X(11).
   05 WS-STUD-PIN PIC 9(5).

PROCEDURE DIVISION.
   A000-FIRST-PARA.
   MOVE 23657891 TO WS-N1.
   MOVE WS-N1 TO WS-N2 WS-N3.
   MOVE WS-N1(2:4) TO WS-N4.
   MOVE 510 TO WS-EMP-HOUSE-NUMBER.
   MOVE 'MAHARASHTRA' TO WS-EMP-STATE.
   MOVE 444601 TO WS-EMP-PIN.
   MOVE WS-EMP-ADDRESS TO WS-STUDENT-ADDRESS.

   DISPLAY "WS-N1     : " WS-N1
   DISPLAY "WS-N2     : " WS-N2
   DISPLAY "WS-N3     : " WS-N3
   DISPLAY "WS-N4     : " WS-N4
   DISPLAY "WS-EMP-ADDRESS  : " WS-EMP-ADDRESS
   DISPLAY "WS-STUDENT-ADDRESS : " WS-STUDENT-ADDRESS

STOP RUN.


Output:
WS-N1     : 23657891
WS-N2     : 23657891
WS-N3     : 57891
WS-N4     : 3657
WS-EMP-ADDRESS  : 510MAHARASHTRA444601
WS-STUDENT-ADDRESS : 510MAHARASHTRA44460

Information about the legal moves are as:

NumericAlphabeticAlphanumeric
NumericPossibleNot PossiblePossible
AlphabeticNot PossiblePossiblePossible
AlphanumericPossiblePossiblePossible
Sours: https://www.tutorialride.com/cobol/move-verb-in-cobol.htm
  1. Bialetti grill pan
  2. 9000 second ave
  3. Laurie lee wells
  4. Eileen fisher fall
  5. 2011 impala

COBOL - Basic Verbs


Advertisements


Previous Page

Next Page  


COBOL verbs are used in the procedure division for data processing. A statement always start with a COBOL verb. There are several COBOL verbs with different types of actions.

Input / Output Verbs

Input/Output verbs are used to get data from the user and display the output of COBOL programs. The following two verbs are used for this process −

Accept Verb

Accept verb is used to get data such as date, time, and day from the operating system or directly from the user. If a program is accepting data from the user, then it needs to be passed through JCL. While getting data from the operating system, FROM option is included as shown in the following example −

ACCEPT WS-STUDENT-NAME. ACCEPT WS-DATE FROM SYSTEM-DATE.

Display Verb

Display verb is used to display the output of a COBOL program.

DISPLAY WS-STUDENT-NAME. DISPLAY "System date is : " WS-DATE.

COBOL PROGRAM

IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-STUDENT-NAME PIC X(25). 01 WS-DATE PIC X(10). PROCEDURE DIVISION. ACCEPT WS-STUDENT-NAME. ACCEPT WS-DATE FROM DATE. DISPLAY "Name : " WS-STUDENT-NAME. DISPLAY "Date : " WS-DATE. STOP RUN.

JCL to execute the above COBOL program −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO //INPUT DD DSN=PROGRAM.DIRECTORY,DISP=SHR //SYSIN DD * TutorialsPoint /*

When you compile and execute the above program, it produces the following result −

Name : TutorialsPoint Date : 200623

Initialize Verb

Initialize verb is used to initialize a group item or an elementary item. Data names with RENAME clause cannot be initialized. Numeric data items are replaced by ZEROES. Alphanumeric or alphabetic data items are replaced by SPACES. If we include REPLACING term, then data items can be initialized to the given replacing value as shown in the following example −

Live Demo IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NAME PIC A(30) VALUE 'ABCDEF'. 01 WS-ID PIC 9(5). 01 WS-ADDRESS. 05 WS-HOUSE-NUMBER PIC 9(3). 05 WS-COUNTRY PIC X(15). 05 WS-PINCODE PIC 9(6) VALUE 123456. PROCEDURE DIVISION. A000-FIRST-PARA. INITIALIZE WS-NAME, WS-ADDRESS. INITIALIZE WS-ID REPLACING NUMERIC DATA BY 12345. DISPLAY "My name is : "WS-NAME. DISPLAY "My ID is : "WS-ID. DISPLAY "Address : "WS-ADDRESS. DISPLAY "House Number : "WS-HOUSE-NUMBER. DISPLAY "Country : "WS-COUNTRY. DISPLAY "Pincode : "WS-PINCODE. STOP RUN.

JCL to execute the above COBOL program −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO

When you compile and execute the above program, it produces the following result −

My name is : My ID is : 12345 Address : 000 000000 House Number : 000 Country : Pincode : 000000

Move Verb

Move verb is used to copy data from source data to destination data. It can be used on both elementary and group data items. For group data items, MOVE CORRESPONDING/CORR is used. In try it option, MOVE CORR is not working; but on a mainframe server, it will work.

For moving data from a string, MOVE(x:l) is used where x is the starting position and l is the length. Data will be truncated if the destination data item PIC clause is less than the source data item PIC clause. If the destination data item PIC clause is more than the source data item PIC clause, then ZEROS or SPACES will be added in the extra bytes. The following example makes it clear.

Live Demo IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9). 01 WS-NUM2 PIC 9(9). 01 WS-NUM3 PIC 9(5). 01 WS-NUM4 PIC 9(6). 01 WS-ADDRESS. 05 WS-HOUSE-NUMBER PIC 9(3). 05 WS-COUNTRY PIC X(5). 05 WS-PINCODE PIC 9(6). 01 WS-ADDRESS1. 05 WS-HOUSE-NUMBER1 PIC 9(3). 05 WS-COUNTRY1 PIC X(5). 05 WS-PINCODE1 PIC 9(6). PROCEDURE DIVISION. A000-FIRST-PARA. MOVE 123456789 TO WS-NUM1. MOVE WS-NUM1 TO WS-NUM2 WS-NUM3. MOVE WS-NUM1(3:6) TO WS-NUM4. MOVE 123 TO WS-HOUSE-NUMBER. MOVE 'INDIA' TO WS-COUNTRY. MOVE 112233 TO WS-PINCODE. MOVE WS-ADDRESS TO WS-ADDRESS1. DISPLAY "WS-NUM1 : " WS-NUM1 DISPLAY "WS-NUM2 : " WS-NUM2 DISPLAY "WS-NUM3 : " WS-NUM3 DISPLAY "WS-NUM4 : " WS-NUM4 DISPLAY "WS-ADDRESS : " WS-ADDRESS DISPLAY "WS-ADDRESS1 : " WS-ADDRESS1 STOP RUN.

JCL to execute the above COBOL program.

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO

When you compile and execute the above program, it produces the following result −

WS-NUM1 : 123456789 WS-NUM2 : 123456789 WS-NUM3 : 56789 WS-NUM4 : 345678 WS-ADDRESS : 123INDIA112233 WS-ADDRESS1 : 123INDIA112233

Legal Moves

The following table gives information about the legal moves −

AlphabeticAlphanumericNumeric
AlphabeticPossiblePossibleNot Possible
AlphanumericPossiblePossiblePossible
NumericNot PossiblePossiblePossible

Add Verb

Add verb is used to add two or more numbers and store the result in the destination operand.

Syntax

Given below is the syntax to Add two or more numbers −

ADD A B TO C D ADD A B C TO D GIVING E ADD CORR WS-GROUP1 TO WS-GROUP2

In syntax-1, A, B, C are added and the result is stored in C (C=A+B+C). A, B, D are added and the result is stored in D (D = A + B + D).

In syntax-2, A, B, C, D are added and the result is stored in E (E=A+B+C+D).

In syntax-3, sub-group items within WS-GROUP1 and WS-GROUP2 are added and the result is stored in WS-GROUP2.

Example

Live Demo IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9) VALUE 10 . 01 WS-NUM2 PIC 9(9) VALUE 10. 01 WS-NUM3 PIC 9(9) VALUE 10. 01 WS-NUM4 PIC 9(9) VALUE 10. 01 WS-NUMA PIC 9(9) VALUE 10. 01 WS-NUMB PIC 9(9) VALUE 10. 01 WS-NUMC PIC 9(9) VALUE 10. 01 WS-NUMD PIC 9(9) VALUE 10. 01 WS-NUME PIC 9(9) VALUE 10. PROCEDURE DIVISION. ADD WS-NUM1 WS-NUM2 TO WS-NUM3 WS-NUM4. ADD WS-NUMA WS-NUMB WS-NUMC TO WS-NUMD GIVING WS-NUME. DISPLAY "WS-NUM1 : " WS-NUM1 DISPLAY "WS-NUM2 : " WS-NUM2 DISPLAY "WS-NUM3 : " WS-NUM3 DISPLAY "WS-NUM4 : " WS-NUM4 DISPLAY "WS-NUMA : " WS-NUMA DISPLAY "WS-NUMB : " WS-NUMB DISPLAY "WS-NUMC : " WS-NUMC DISPLAY "WS-NUMD : " WS-NUMD DISPLAY "WS-NUME : " WS-NUME STOP RUN.

JCL to execute the above COBOL program −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO

When you compile and execute the above program, it produces the following result −

WS-NUM1 : 000000010 WS-NUM2 : 000000010 WS-NUM3 : 000000030 WS-NUM4 : 000000030 WS-NUMA : 000000010 WS-NUMB : 000000010 WS-NUMC : 000000010 WS-NUMD : 000000010 WS-NUME : 000000040

Subtract Verb

Subtract verb is used for subtraction operations.

Syntax

Given below is the syntax for Subtract operations −

SUBTRACT A B FROM C D SUBTRACT A B C FROM D GIVING E SUBTRACT CORR WS-GROUP1 TO WS-GROUP2

In syntax-1, A and B are added and subtracted from C. The result is stored in C (C = C-(A+B)). A and B are added and subtracted from D. The result is stored in D (D = D-(A+B)).

In syntax-2, A, B, C are added and subtracted from D. The result is stored in E (E = D-(A+B+C))

In syntax-3, sub-group items within WS-GROUP1 and WS-GROUP2 are subtracted and the result is stored in WS-GROUP2.

Example

Live Demo IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9) VALUE 10 . 01 WS-NUM2 PIC 9(9) VALUE 10. 01 WS-NUM3 PIC 9(9) VALUE 100. 01 WS-NUM4 PIC 9(9) VALUE 100. 01 WS-NUMA PIC 9(9) VALUE 10. 01 WS-NUMB PIC 9(9) VALUE 10. 01 WS-NUMC PIC 9(9) VALUE 10. 01 WS-NUMD PIC 9(9) VALUE 100. 01 WS-NUME PIC 9(9) VALUE 10. PROCEDURE DIVISION. SUBTRACT WS-NUM1 WS-NUM2 FROM WS-NUM3 WS-NUM4. SUBTRACT WS-NUMA WS-NUMB WS-NUMC FROM WS-NUMD GIVING WS-NUME. DISPLAY "WS-NUM1 : " WS-NUM1 DISPLAY "WS-NUM2 : " WS-NUM2 DISPLAY "WS-NUM3 : " WS-NUM3 DISPLAY "WS-NUM4 : " WS-NUM4 DISPLAY "WS-NUMA : " WS-NUMA DISPLAY "WS-NUMB : " WS-NUMB DISPLAY "WS-NUMC : " WS-NUMC DISPLAY "WS-NUMD : " WS-NUMD DISPLAY "WS-NUME : " WS-NUME STOP RUN.

JCL to execute the above COBOL program −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO

When you compile and execute the above program, it produces the following result −

WS-NUM1 : 000000010 WS-NUM2 : 000000010 WS-NUM3 : 000000080 WS-NUM4 : 000000080 WS-NUMA : 000000010 WS-NUMB : 000000010 WS-NUMC : 000000010 WS-NUMD : 000000100 WS-NUME : 000000070

Multiply Verb

Multiply verb is used for multiplication operations.

Syntax

Given below is the syntax to multiply two or more numbers −

MULTIPLY A BY B C MULTIPLY A BY B GIVING E

In syntax-1, A and B are multipled and the result is stored in B (B=A*B). A and C are multipled and the result is stored in C (C = A * C).

In syntax-2, A and B are multipled and the result is stored in E (E=A*B).

Example

Live Demo IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9) VALUE 10 . 01 WS-NUM2 PIC 9(9) VALUE 10. 01 WS-NUM3 PIC 9(9) VALUE 10. 01 WS-NUMA PIC 9(9) VALUE 10. 01 WS-NUMB PIC 9(9) VALUE 10. 01 WS-NUMC PIC 9(9) VALUE 10. PROCEDURE DIVISION. MULTIPLY WS-NUM1 BY WS-NUM2 WS-NUM3. MULTIPLY WS-NUMA BY WS-NUMB GIVING WS-NUMC. DISPLAY "WS-NUM1 : " WS-NUM1 DISPLAY "WS-NUM2 : " WS-NUM2 DISPLAY "WS-NUM3 : " WS-NUM3 DISPLAY "WS-NUMA : " WS-NUMA DISPLAY "WS-NUMB : " WS-NUMB DISPLAY "WS-NUMC : " WS-NUMC STOP RUN.

JCL to execute the above COBOL program −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO

When you compile and execute the above program, it produces the following result −

WS-NUM1 : 000000010 WS-NUM2 : 000000100 WS-NUM3 : 000000100 WS-NUMA : 000000010 WS-NUMB : 000000010 WS-NUMC : 000000100

Divide Verb

Divide verb is used for division operations.

Syntax

Given below is the syntax for division operations −

DIVIDE A INTO B DIVIDE A BY B GIVING C REMAINDER R

In syntax-1, B is divided by A and the result is stored in B (B=B/A).

In syntax-2, A is divided by B and the result is stored in C (C=A/B) and the remainder is stored in R.

Example

Live Demo IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9) VALUE 5. 01 WS-NUM2 PIC 9(9) VALUE 250. 01 WS-NUMA PIC 9(9) VALUE 100. 01 WS-NUMB PIC 9(9) VALUE 15. 01 WS-NUMC PIC 9(9). 01 WS-REM PIC 9(9). PROCEDURE DIVISION. DIVIDE WS-NUM1 INTO WS-NUM2. DIVIDE WS-NUMA BY WS-NUMB GIVING WS-NUMC REMAINDER WS-REM. DISPLAY "WS-NUM1 : " WS-NUM1 DISPLAY "WS-NUM2 : " WS-NUM2 DISPLAY "WS-NUMA : " WS-NUMA DISPLAY "WS-NUMB : " WS-NUMB DISPLAY "WS-NUMC : " WS-NUMC DISPLAY "WS-REM : " WS-REM STOP RUN.

JCL to execute the above COBOL program −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO

When you compile and execute the above program, it produces the following result −

WS-NUM1 : 000000005 WS-NUM2 : 000000050 WS-NUMA : 000000100 WS-NUMB : 000000015 WS-NUMC : 000000006 WS-REM : 000000010

Compute Statement

Compute statement is used to write arithmetic expressions in COBOL. This is a replacement for Add, Subtract, Multiply, and Divide.

Example

Live Demo IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9) VALUE 10 . 01 WS-NUM2 PIC 9(9) VALUE 10. 01 WS-NUM3 PIC 9(9) VALUE 10. 01 WS-NUMA PIC 9(9) VALUE 50. 01 WS-NUMB PIC 9(9) VALUE 10. 01 WS-NUMC PIC 9(9). PROCEDURE DIVISION. COMPUTE WS-NUMC= (WS-NUM1 * WS-NUM2) - (WS-NUMA / WS-NUMB) + WS-NUM3. DISPLAY "WS-NUM1 : " WS-NUM1 DISPLAY "WS-NUM2 : " WS-NUM2 DISPLAY "WS-NUM3 : " WS-NUM3 DISPLAY "WS-NUMA : " WS-NUMA DISPLAY "WS-NUMB : " WS-NUMB DISPLAY "WS-NUMC : " WS-NUMC STOP RUN.

JCL to execute the above COBOL program.

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO

When you compile and execute the above program, it produces the following result −

WS-NUM1 : 000000010 WS-NUM2 : 000000010 WS-NUM3 : 000000010 WS-NUMA : 000000050 WS-NUMB : 000000010 WS-NUMC : 000000105

Previous Page

Print

Next Page  


Sours: https://www.tutorialspoint.com/cobol/cobol_basic_verbs.htm
Move verb in COBOL

cobol MOVE statement

is the workhorse of COBOL. Data is moved from literal or identifier to one or more identifiers. COBOL has a distinction between elementary and group MOVE. Elementary data is type converted from source to destination. Group data is moved as a byte array, without regard to field types with a structure. Numeric fields are moved from right to left, high order digit truncation with zero fill (normally). Alphanumeric character data is moved left to right, right end character truncation with space fill. There are quite a few rules on how goes about its business, with both BINARY and PICTURE DISPLAY data forms, and group hierarchies all accounted for.

enter image description here

MOVE statement Related Examples






Sours: https://riptutorial.com/cobol/topic/7263/move-statement

In cobol move

The MOVE corresponding is a group move but the elementary items of sending group item should match with elementary items of receiving item. MOVE CORRESPONDING only affects data-items that are having identical names in both sending and receiving group items.

MOVE CORRESPONDING doesn't affect the elementary items in the sending or receiving records which are not matching. MOVE CORRESPONDING automatically searches for the corresponding elementary items to move the data from sending item to receiving item.

Sending item in MOVE statement can be an alphanumeric group item. Receiving item in MOVE statement should be an alphanumeric group item but not literal or a figurative constant.

Syntax -

MOVE CORRESPONDING Syntax

identifier-1

Specifies sending area.

identifier-2

  • Specifies receiving areas.
  • All identifiers can reference alphabetic or numeric or alphanumeric group items.
Practical Example -

Code:
MOVE Corresponding Program Code

In the above example, FULL-NAME declared as of length 30 with three elementary items FIRST-NAME, MIDDLE-NAME and LAST-NAME of length 10 each.

Similarly FULL-NAME-REV is declared with same length 30 with three elementary items in the order LAST-NAME, MIDDLE-NAME and FIRST-NAME of length 10 which are the reverse order of FIRST-NAME.

The input is accepted from SYSIN for the three elementary items.

After all ACCEPT statements executed, the values of elementary items will be


FIRST-NAME will have MAINFRAMES MIDDLE-NAME will have TECH LAST-NAME will have HELP

To move the elementary items to another group item, we need three simple move statements.

This one can be accomplished by using a CORRESPONDING MOVE likes below -

MOVE CORRESPONDING FULL-NAME TO FULL-NAME-REV.

The above move statement will do the below tasks

  1. Moving FIRST-NAME of FULL-NAME to FIRST-NAME of FULL-NAME-REV
  2. Moving MIDDLE-NAME of FULL-NAME to MIDDLE-NAME of FULL-NAME-REV
  3. Moving LAST-NAME of FULL-NAME to LAST-NAME of FULL-NAME-REV

Jcl -

MOVE Corresponding Jcl

Output -

MOVE Corresponding Output
Sours: https://www.mainframestechhelp.com/tutorials/cobol/move-corresponding.htm
COBOL 6 Sign and Decimals

The MOVE Statement

When a numeric or numeric-edited item is the receiving item, alignment by decimal point and any necessary zero-filling takes place as defined in the section Standard Alignment Rules in the chapter Concepts of the COBOL Language, except where zeros are replaced because of editing requirements.

ANS85 When the sending operand is numeric-edited, de-editing is implied to establish the operand's unedited numeric value, which can be signed; then the unedited numeric value is moved to the receiving field. The effect of de-editing depends on the setting of the DE-EDIT Compiler directive

When a signed numeric item is the receiving item, the sign of the sending item is placed in the receiving item. (See the topic The SIGN Clause.) Conversion of the representation of the sign takes place as necessary. If the sending item is unsigned, a positive sign is generated for the receiving item.

When an unsigned numeric item is the receiving item, the absolute value of the sending item is moved and no operational sign is generated for the receiving item.

When a data item described as alphanumeric is the sending item, data is moved as if the sending item were described as an unsigned numeric integer.

When the receiving item is numeric or numeric-edited and the sending item is defined as alphanumeric, if the content of the sending item is not an integer, the results of the move are undefined. If the alphanumeric sending item is a literal whose contents do not represent an integer, an error is reported, and zero moved to the target. (See the topic Incompatible Data in the chapter Procedure Division.)

ANS85 When the numeric data item is the sending item the action of the move is such that a reverse of the move would cause the same value to appear in the numeric-edited field (except for truncation). If the data item contains data which does not conform to the edited picture, zero is moved to the target.

Sours: https://www.microfocus.com/documentation/visual-cobol/vc50pu3/EclWin/HRLHLHPDFA02.html

Now discussing:

Quiet. There will be sighs, and even screams, only not on the bench, but on the beds. I continue to expound.



300 301 302 303 304