IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

HOW TO MOVE NON-FIXED DATA?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ann

New User


Joined: 10 Aug 2005
Posts: 3

PostPosted: Wed Aug 10, 2005 10:55 pm
Reply with quote

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.
Back to top
View user's profile Send private message
ironmike

New User


Joined: 07 Aug 2005
Posts: 33

PostPosted: Thu Aug 11, 2005 4:24 am
Reply with quote

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...
Back to top
View user's profile Send private message
dinesh_mf

New User


Joined: 26 May 2005
Posts: 15
Location: maharashtra

PostPosted: Mon Aug 22, 2005 10:13 pm
Reply with quote

Hi Ironmike,
Thats a very good and comprehensive explaination. Thanks.

Dinesh
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top