Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read in

Status
Not open for further replies.

gmupats

Technical User
Mar 21, 2001
1
US
I'm trying to determine if a numeric field is a debit or a credit. IF the field starts with a "-" it's a debit, ELSE it's a credit. I'm not sure how do do this? Any help, or suggestions?

Would it be something like:

IF FIELDX CONTAIN "-" MOVE TO DEBIT
ELSE MOVE TO CREDIT?

Basically, I'm not sure how I look for one character in a field.

Thanks for your help.
 
Is this field a numeric field? If so you could check to see if the amount is < 0. The terms debit & credit are best defined by your accounting weenies.
 
Hi G,

I'm assuming if the field is positive, the leading char
is a +. If so, the trick is to define the field as follows:

05 ws-fld-a pic s9(03)v99 sign is leading separate.

Note that the above defines a six digit field: a 5 digit # plus 1 digit for the sign. Also if the field is 12345- use trailing instead of leading.

If a positive field contains a space (' '), you can do the following:

05 ws-fld-grp.
10 ws-sign pic x.
10 ws-fld-a pic s9(03)v99.

if ws-sign = '-'
compute ws-fld-a = ws-fld-a * -1
end-if

From here just use ws-fld-a in any math functions.

Hope this helps, Jack.


 
hi g,
providing that you have defined the relevant data definitions to cater for reading in the sign, you can just code:
IF FIELDX IS NEGATIVE THEN
MOVE TO DEBIT
ELSE
MOVE TO CREDIT
END-IF.

good luck, jimlee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top