× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 7/31/2015 8:42 AM, (WalzCraft) Jerry Forss wrote:
Hi All,

I have a program that will take any IBMi file and create an excel.
Works great and is used daily. Users are creating new files using Query all the time.

I retrieve the fields for the file using QUSLFLD and are loaded into arrays.

FInput IF F32766 DISK UsrOpn ExtFile(FileOverride)
F InfDS(InputDS)

DInputDS DS
D InputRecords 156 159I 0
D InputRRN 397 400I 0

D DS INZ
D NumericFld 1 16P 0
D AlphaFld 1 16

IINPUT NS
I 132766 InputData

// Seperate Field
Data = %SubSt(InputData : FldStart(X) : FldLength(x));

// Load Field From String
%SubSt(AlphaFld : 17 - FldLength(X)) = %Trim(Data);

Here is the scenario.
The field must be packed, odd number of digits, must be using all digits AND first 2 digits contain 40.
Example: P5,0 contains 40000 it fails. If it contains 4000 no issue. If it contains 41000 no issue.

I read a record from Input and start parsing out the fields.

When it does the SubSt to the alphafld the result (NumericFld) contains invalid data and further in the code gets a decimal data error. Yes, I can add a monitor to trap it.

I know when it is going to happen because I can test on field type (P), length (Odd digits) and first position of Data contains X'40'.

First, Why does it decide to interpret the X'40' as a space I assume only in the scenario?

'It' is %trim(), and the entire purpose of %trim() is to remove x'40'
from the front and the back of character fields, which DATA is.

What can I do about it?

Is there a better way of parsing out the data?

%SubSt(AlphaFld : 17 - FldLength(X)) = %SubSt(InputData : FldStart(X) :
FldLength(x));



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.