Search code examples
ibm-midrange

How to add editing and validation rules to CL programming? (As400)


please note this is a 'expand your knowledge' (optional task) for college, not an assignment

I have a physical file called INVFILE and a logical file called INVFILE1

I have the CL program called INVCL99

this these are my columns for INVFILE1

R INVFILE 1
  PARTDESC
  ONHAND
  UNITCOST
  STOCK
  PARTNUM
K PARTNUM

this is the code for my CL program

PGM

         SNDUSRMSG MSG('EXECUTING INVENTORY PROGRAM, PRESS ENTER')

         CHGDTA DFUPGM(INVENTORLB/INVENTORY) FILE(INVENTORLB/INVFILE1)

ENDPGM

What I'd like to be able to do, is to validate the STOCK column. as it stands it only accepts 1 character, or no characters.

I'd like to validate it so that it can only accept 1 specific character * or be left blank, nothing else can be inputted.

I've been googling trying to find some sources that will help me out with this, but unfortunately I can't find anything. Any chance someone can tell me where to look? or tell me what I need to do?

Also, not sure if I should create another question for this, but I have been trying to use numerous ways to be able to input decimals in my DFU programs example : Total Amount Purchased 2300.29, I've tried floats which caused problems, and I've tried packed decimals, but I can't seem to figure out how to allow decimals / periods to be inputted.

Thanks.


Solution

  • The DFU enables specifying for a column, from the Work with Fields panel, 2=Specify Extended Definition, then 2=Change for the Validity checks prompt, where at the Specify Validity Checks panel the arguments of the DDS VALUES keyword can be specified on the List of values prompt if\when the Relational Operator prompt is set to LS=List of values.

    Because the specifying of VALUES() in a database file DDS [PF or LF] has no effect outside of what is provided by program generators and the DDS compiler for Create Display File (CRTDSPF) [the database cares not about the designation for actual I\O], the only benefit in having the VALUES coded in the PF or LF DDS is to ensure that both DFU and CRTDSPF see the same input restrictions; the PF often the better choice to carry the attribute up to the LF and into those other places. Note: the DDS compiler for Create Printer File (CRTPRTF) recognizes other keywords, but not VALUES, because the PRTF is output-only vs allowing input like the DSPF].

    I forget how to code the DDS for the DSPF to override the inability to type the period for the decimal point, but I seem to recall with the addition of an Edit Code (EDTCDE) and removal of the CHECK keyword that keying the decimal point is possible; ask the DFU to save the DDS and then review what that feature generated, and then a customized version can be created and used. The other irritating effect for DFU is the forced Upper-Case; as I recall that is a DSPATR keyword setting that can be changed. The interactive DFU code generator may, like the ability to code limited values, specify capabilities for either\both of those issues, but I do not recall and a cursory look I did not see anything.