Substring A Packed Field

520 pts.
Tags:
Array
Data Structure to Flat File
Data structures
Flat files
Packed Fields
Substring
Hello I have a flat record format that I move into an external data structure. Within the external data structure, I have many packed fields. Rather than refer to each of pacekd field by external field name, I would like to be able to substring each packed field out, and then, move the value of each packed field into an array. Can any one help me out with this ? Also, please email me the web site where the answer is, because for whatever reason, I can't seem to track where my questions are going. nick.serio@jbmcci.com Thanks, Nick

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 18  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • MelanieYarbrough
    Hi Nick, Each question that you post in the forum is automatically added to your watchlist, which you can easily access by clicking on the tab "My Watchlist" located at the top of the screen underneath the IT Knowledge Exchange logo on the far right. Hope this helps! If you're having trouble, feel free to email me at Melanie [at] ITKnowledgeExchange [dot] com. - Melanie
    6,345 pointsBadges:
    report
  • Piano
    I should mention why I need to be able to do this. I have files that I am auditing. Rather than design separate listings for each file that is being audited, I would like to be able to move the file format to its appropriate external data structure, Then, rather than refer to each external field name, I could "substring" the values out and store into 2 separate arrays. One would be the before value, and the other would be the after value. Trouble is, I have packed fields and numeric fields. Not sure how to extract these out ?
    520 pointsBadges:
    report
  • TomLiotta
    What language are you trying to use? What version of the OS? What kind of "file" is it -- streamfile? database file? Tom
    125,585 pointsBadges:
    report
  • Piano
    [...] from: Substring A Packed Field AKPC_IDS += "15855,";Popularity: unranked [...]
    0 pointsBadges:
    report
  • Piano
    Hi Tom I am writing this in RPGL, the O/S level is V6R1, and the file is a database file. Thzanks, Nick
    520 pointsBadges:
    report
  • philpl1jb
    Nick I think that you will find that the easiest way to go is to build the data structures for each record. If you insist on substring and converting the substrings I think it might look something like this. My90ds DS My90Alpha 5A My90 9P 0 overlay My90ds When you substring a part of the string that was 9p 0 and put it into My90Alpha you will either get 1. The value in My90 2. A data decimal error Phil
    49,720 pointsBadges:
    report
  • TomLiotta
    I could “substring” the values out and store into 2 separate arrays. By saying "array", you imply that every packed value has the same definition -- same precision and scale. I have packed fields and numeric fields. A packed field is a numeric field. You apparently mean that there are zoned decimal and possibly integer/binary fields in addition to packed decimal fields. Character fields would seem reasonably likely. IOW, a normal database file with various field definitions. You seem to want to process before and after images, like journal entries. Are you wanting to highlight changes? Or will you just list the images? It's not exactly necessary to substring anything nor exactly to design any listings if that's what you want to do. If it's not what you want to do, please describe the differences. I might be able to provide a technique that will help. Tom
    125,585 pointsBadges:
    report
  • Piano
    Hi Tom I want to be able to list any changes done to any field for a particular file. This listing would include the user id, change date, and change time. The thing is, since I have multiple files, I am trying to avoid having to design multiple listings. So, i figured I could move the record format (Flat), to an external data strucutre. This part works great. Now, once in the external data structure, I need to be able to somehow print out the differences without having to refer to each field name within the external data strucutre. Actually, I have 2 external data strucutres, one for the before image, and one for the after image. Hope this helps Nick Nick
    520 pointsBadges:
    report
  • TomLiotta
    I could move the record format (Flat),... That's a part that isn't clear. Why is it flat? How is it created? Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    I'm asking how it was created because you haven't mentioned journaling yet (or I keep missing it.) If it's "flat" because it's a journal image, it might be very different from some application- or utility-created file. Tom
    125,585 pointsBadges:
    report
  • Piano
    Hi Tom I have an application program that writes out the change date, change time, and two 700 byte fields which are the before and after values of the file being audited. . I am in the process of developing a listing program. So far, my program moves each 700 byte field into an external data structure which is defined as the recrod format of hte file being audited with the prefix O_ for old, and C_ for current. So now that I have the external field values, I want to be able to compare the old value with the current value of each field without referencing them by field name. (if I reference each field by name, then I have to have a separate listing program for each file. I am trying to avoid having to do this.) In addition, I need to be able to convert packed/numeric fields. Thanks, Nick . .
    520 pointsBadges:
    report
  • TomLiotta
    ...two 700 byte fields which are the before and after values of the file being audited. But where do those 700-byte fields come from? Do you actually have application files with single 700-byte fields that have internally-described subfields? Are these emitted from trigger programs? Are they S/36 record images? Or do you actually have code that deliberately constructs flat images from a set of values derived from file fields? I think my confusion comes from use of the term "auditing" back in the beginning. An audit normally implicitly implies a capability of external verification. That means that some external definition must be available to use to validate results. So, you might create the 700-byte field by way of copying a physical record format on top of the 700-byte field. That would enable clear recovery of the values by some fairly simple uses of basic database utility functions. The external definition can be used in the extraction process. But the way that it would be used will vary somewhat depending on how it was used to "encode" the format at the start. So, where do the "before and after images" come from? How do you know what those images contain? That will point to the basis of "decoding" the 700-byte fiels. Tom
    125,585 pointsBadges:
    report
  • Piano
    Hi Tom In answer to your question, I have code that deliberately constructs flat images from a set of values derived from file fields. For example, when an operator is in the Payroll Employee Maintenance Program, I pass the values of the employee master external fields as two large 700 byte parameters, one the before image, and the second the after image. An external call is executed where the 700 byte fields gets written out, along with the user id, change date, change time, file name, and file key. Now, when I want to design the listing, I am trying to have one listing for any file that is being audited rather than having separate listings. Not sure if this is even possible. Nick
    520 pointsBadges:
    report
  • philpl1jb
    Nick So would or could you have a physical file for each of these datastructures? Phil
    49,720 pointsBadges:
    report
  • TomLiotta
    I pass the values of the employee master external fields... Here it is again. How is the order of the "employee master external fields" chosen by your program? Did you simply pick field definitions in a random sequence and concatenate them into a 700-byte string variable? Or did you use some method such as overlaying the employee master external definition on a DS? If it was a method, what was it? If you created the content of the 700-byte field from an external 'template' like the record format, then we have a dynamic basis for extracting the fields back out. But if you simply put Fld_1 followed by Fld_7, Fld_4, Fld_2, Fld_9, etc., in some order known only to the program code (possibly mixing in program variables and omitting one or more unnecessary employee master fields)... then it will require more program code that will be unique for every file to extract it back out. How does your program know where to put each subfield in your 700-byte variable? Tom
    125,585 pointsBadges:
    report
  • Piano
    Hi Tom Here is a ample of the maintenance program. IEMPMAS NS I 1 2 0ECOMNO I 3 7 0EEMPNO I 8 8 ESTATU I . I . I . I 1 350 EMPDATA. In the program, I initially chain to EMPMAS. I move EMPDATA to a field called OLDDATA defined as 350. After changes are made by the operator, EMPMAS gets updated. At this point, I rechain to the file and move EMPDATA to a field called NEWDATA. So now I have my old and new images which get passed as parameters along with the File Name (EMPMAS), and File Key (ECOMNO, EEMPNO). I do a movel of OLDDATA and NEW DATA to two 700 byte fields, and then write out the audit record. Note that EMAS has DDS and is externally defined. Nick
    520 pointsBadges:
    report
  • philpl1jb
    So if you issue a DSPFFD empmas you would get the necessary structural information..starting positions, number of bytes, type, number of decimals. The dspffd can be output to an outfile so your program can use it. Compare the two strings Where there is a difference Get field structure from FFD extract field based on position and length in FFD and then decode packed That's where you would move it to a character field which overlays a packed field of the correct format. -- thats into My90Alpha and out of My90. Phil
    49,720 pointsBadges:
    report
  • TomLiotta
    So now I have my old and new images... That clarified things greatly. Now I see that each record has duplicate record images, which means that each subfield definition is duplicated. That throws a snag into it, but I'm looking at modifying methods to account for that. Personally, I'd toss this as fast as I could and simply journal the changes -- everything would be much easier and it would actually be a valid "audit" trail. But that's not part of the question, so there's no point in belaboring the obvious. I'll see what can be worked up as a prototype. I have code of my own that does it for any file, but it now needs to account for the conflict of duplicated columns. We'll see... Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following