|
You are correct. I've never had the need to convert in the other direction so I've given that no thought at this point in time. Let me know what you come up with on it! -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Lim Hock-Chai Sent: Monday, June 20, 2005 1:29 PM To: RPG programming on the AS400 / iSeries Subject: RE: how to populate the field when thefieldnameisstored:Actuallythere are lot more fields seems like the code below is to convert pack field in the file to a string field. Is that right? My question is more toward converting a string field into pack field that you can substr it into the pack field in the file using the method described. -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Shannon ODonnell Sent: Monday, June 20, 2005 1:05 PM To: 'RPG programming on the AS400 / iSeries' Subject: RE: how to populate the field when the fieldnameisstored:Actuallythere are lot more fields Good question! I never tried this on XML data. But basically, what I do with packed data in a DB2 database is to convert the hex value to a character value. *--------------------------------------------------------------------- * ExtPack - Extract Packed Data from DS *--------------------------------------------------------------------- C ExtPack Begsr * **** C Eval filwrk = DataFile C Eval Hexstring = %Subst(filwrk:iBps:iLen) **** * C eval NumHex = 0 C Evalr Char16 = %subst(hexstring:1:iLen) C Eval CharField = %char(NumHex) C If NumHex >= 0 C Eval Sign = '+' C Else C Eval Sign = '-' C Endif * C Endsr * ---------------------------------------------------------------------------- -- -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Lim Hock-Chai Sent: Monday, June 20, 2005 12:54 PM To: RPG programming on the AS400 / iSeries Subject: RE: how to populate the field when the field nameisstored:Actuallythere are lot more fields Haven't had a chance to read the whole article. Seems like the method is similar. If the field is a pack decimal and the data is in xml file. How do you convert the string data in the xml into a pack format? -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Shannon ODonnell Sent: Monday, June 20, 2005 12:48 PM To: 'RPG programming on the AS400 / iSeries' Subject: RE: how to populate the field when the field name isstored:Actuallythere are lot more fields Here's one way to do it. It works for all data types. http://www.itjungle.com/mpo/mpo112102-story01.html -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Lim Hock-Chai Sent: Monday, June 20, 2005 12:26 PM To: RPG programming on the AS400 / iSeries Subject: RE: how to populate the field when the field name is stored:Actuallythere are lot more fields you can use QUSLFLD to get the field output location and then substring the data to the field location. This method will not work for some field types such as pack decimal. Here is the basic flow: 1) A service program with an export procedure that accept file name, record format name and field offset and field length . example: rtvFieldOutputLoc("MYFILE" :"MYFILEFMT" :myField :myOffset :myLen) The hard part is to create this service program, it basically need to do the following in the above procedure: 1.1) call QUSLFLD to get the file field layout and put the result in user index. (For speed, if already exist, do not need to do this step) 1.2) Lookup the field offset and length from the above user index and return to the called. 2) In the caller program: 2.1) in D speac D wkMYFILE likerec(MYFILEFMT :*output) 2.1) in C Spec C callp rtvFieldOutputLoc("MYFILE" :"MYFILEFMT" C :myField :myOffset :myLen) C eval %subst(wkMYFILE :myOffset :myLen) = myValue -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Banerjee, Amitava Sent: Friday, June 17, 2005 12:41 PM To: rpg400-l@xxxxxxxxxxxx Subject: how to populate the field when the field name is stored: Actuallythere are lot more fields Hi All, Thanks for the help. Actually right now I am using 'SELECT' opcode. But, in reality the file1 does not have only those many fields. It will have hundreds of tags with hundreds of field names. This is actually extracting data from xml file. That's why I was thinking if there is any better way to do this. Thanks Amitava
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.