ann
New User
Joined: 10 Aug 2005 Posts: 3
|
|
|
|
Hi,
CAN U TELL ME HOW TO MOVE VARIABLE LENGTH DATA TO WORK AREA ? AND IT MAY OVER 256BYTES......... I KNEW THAT IF THE DATA IS BELOW 256 BYTES AND FIXED LENGTH MOVEMENT AS FOLLOWING......
EX:
MVC OUTPUTDATA+4(10),INPUTDATA
IT TAKES FIXED "10" BYTES LENGTH DATA FROM INPUTDATA
IF I WANT TO MOVE NON-FIXED DATA LENGTH TO OUTPUTDATA+4, HOW CAN I DO?
IS
MVC OUTPUTDATA+4('LINPUTDATA),INPUTDATA ??
HOW ABOUT OVER 256 BYTES????
THANKS ALL. |
|
ironmike
New User
Joined: 07 Aug 2005 Posts: 33
|
|
|
|
Well, you could use the MVCL instruction, but you do have to set a limit on the defined length of the work area in most cases. I presume you are moving all or part of a variable length record that you have obtained with a GET macro, correct? Your labels are OUTPUTDATA and INPUTDATA, but you don't say how you got the variable length data to begin with. I will assume a QSAM GET with MACRF=L in the DCB for now. If you are using GETs with VSAM, the rules change.
Now, if you did a GET with DCB MACRF=L, then the address of the record you read is returned in R1 (register one). You should save that address in another register, then use MVCL to move all or part of the data to your work area. MVCL works if you are only moving one byte, or if you are moving up to 2,147,483,647 bytes.
Code: |
...
GET INFILE READ RECORD
LR R2,R1 SAVE ITS ADDRESS
LH R3,0(,R2) GET SIZE OF RECORD
L R5,=A(L'OUTPUTDATA) GET LENGTH OF OUTPUT AREA
CR R3,R5 SEE IF RECORD WILL FIT
BH NOMVCL SKIP MVCL IF NOT
LA R4,OUTPUTDATA GET ADDRESS OF OUTPUT AREA
MVCL R4,R2 MOVE THE FULL RECORD THERE
NOMVCL DS 0H
.... |
The code above GETs the record, save it's address in register 2, then puts the length of the record in R3 by loading it from the halfword RDW (record descriptor word) which is at the front of each variable length record read via QSAM GET. The length of the output area is placed in R5 and a compare is done to make sure the record will fit into the output area. If it fits, then R4 is set to the address of the output area and MVCL (move long) is used to move the record from the QSAM buffer to the output area. If the record won't fit, then the MVCL is skipped.
MVCL, as coded above, moves TO the address in R4 FROM the address in R2. R3 and R5 contain the sending and receiving lengths, respectively.
This is an over simplified example. You could just as well move part of the record also. The optimum way to handle this is to just access the record where it sits in the QSAM buffer (R1 points to the record after GET executes) and move fields from it to your output area. You should read up on MVCL before you use it, AND adapt the ideas in this example to your code...this is an example only, not a usable program... |
|