How do you code a Move statement starting at a specific position, and using a specific length?
search cancel

How do you code a Move statement starting at a specific position, and using a specific length?

book

Article ID: 12952

calendar_today

Updated On:

Products

PanAudit Plus Easytrieve Report Generator PAN/SQL

Issue/Introduction

Coding a customized MOVE statement in Easytrieve.



Using Easytrieve, can I move data, starting at a specific position, and using a  specific length?

An example would be helpful.   

Environment

Coding an example of a customized MOVE statement using Easytrieve

Resolution

Using the following code, will move 50 positions of data, starting at the 83rd position of the table; 

FILE DUMMY 

DEFINE LETTERS W 254 A VALUE + 

'ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCDEFGHIJKLMNOPQRSTUVWX +  <=== 83rd position is an "H"

ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCDEFGHIJKLMNOPQRSTUVWX + 

ABCD' 

 

DEFINE TBL-WORK LETTERS 1 A + 

OCCURS (254) 

 

DEFINE SNGL-FLD W 100 A 

DEFINE WS-DYN-LEN W 2 B VALUE 50 

DEFINE WS-START-MOVE W 2 B VALUE 83 

 

******************************************************** 

JOB INPUT NULL 

DISPLAY 'SINGLE-FIELD' SNGL-FLD 

DISPLAY HEX SNGL-FLD 

MOVE TBL-WORK (WS-START-MOVE) WS-DYN-LEN TO SNGL-FLD 

DISPLAY 'SINGLE-FIELD' SNGL-FLD 

DISPLAY HEX SNGL-FLD 

STOP 

// 

The previous code produced the following output. 

I Displayed SNGL-FLD before the move, it was all Spaces; 

SINGLE-FIELD 

 

CHAR 

ZONE 44444444444444444444444444444444444444444444444444 

NUMR 00000000000000000000000000000000000000000000000000 

 

Then starting at the 83rd position of my table, I moved 50 bytes to SNGL-FLD; 

 

CHAR HIJKLMNOPQRSTUVWX ABCDEFGHIJKLMNOPQRSTUVWX ABCDEFG 

ZONE CCDDDDDDDDDEEEEEE4CCCCCCCCCDDDDDDDDDEEEEEE4CCCCCCC444 

NUMR 89123456789234567012345678912345678923456701234567000  

 

If you look at the table, the 83th position was an "H".