Example 1: toleration of decimal fields

Testing the automatic correction of invalid data in a decimal field.

About this task

This scenario shows how the default value 0 can be automatically set in decimal fields that contain invalid data.

Procedure

  1. Generate the JSON schema and necessary artifacts for CICS® to transform between JSON and COBOL application data.
    1. Prepare the copybook.
      03 BAD-DATA.
      05 NORMAL-NUM PIC 9(2).
      05 NORMAL-CHAR PIC X(3).
      05 PZONED-DECIMAL PIC S9(4) DISPLAY.
      05 NZONED-DECIMAL PIC S9(4) DISPLAY.
      05 UZONED-DECIMAL PIC 9(4) DISPLAY.
      05 NORMAL-CHAR2 PIC X(3).
      05 PBINARY PIC S9(4) BINARY.
      05 NBINARY PIC S9(4) COMP.
      05 UBINARY PIC 9(4) COMP.
      05 NORMAL-NUM2 PIC 9(3).
      05 PPACKED-DECIMAL PIC S9(4) COMP-3.
      05 NPACKED-DECIMAL PIC S9(4) COMP-3.
      05 UPACKED-DECIMAL PIC 9(4) COMP-3.
      05 NORMAL-NUM3 PIC 9(2).
      05 NORMAL-CHAR3 PIC X(3).
      05 FLOAT-ZONED PIC S9(4)V99.
      05 FLOAT-PACKED PIC S9(4)V99 COMP-3.
    2. Submit the JCL.
      Set DATA-SCREENING to DISABLED to activate the function.
      //GENJSON JOB ('accounting information',name),CLASS=M,REGION=0M,
      // MSGCLASS=A,NOTIFY=&SYSUID
      //JCLLIB JCLLIB ORDER=ZZZZ.A.ZOSCONN.JCL
      //LS2JS EXEC DFHLS2JS,
      // JAVADIR='/java/java7_64/J7.0_64',
      // USSDIR='cics.ts.test/tolerate',
      // PATHPREF='',
      // TMPDIR='/tmp',
      // TMPFILE=''
      //INPUT.SYSUT1 DD *
      PDSLIB=ZZZZ.A.ZOSCONN.COPYBOOK
      REQMEM=BADDATA
      RESPMEM=BADDATA
      JSON-SCHEMA-REQUEST=/u/zzzz/json/ls2js/baddata1_request.json
      JSON-SCHEMA-RESPONSE=/u/zzzz/json/ls2js/baddata1_response.json
      LANG=COBOL
      LOGFILE=/u/zzzz/json/ls2js/baddata1.log
      MAPPING-LEVEL=4.1
      DATA-SCREENING=DISABLED
      CHAR-VARYING=COLLAPSE
      PGMNAME=baddata1
      URI=/baddata1
      PGMINT=COMMAREA
      WSBIND=/u/zzzz/json/ls2js/baddata1.wsbind
      /*
    3. Check that the generated JSON schemas (request and response) and WSBind files were created successfully.
  2. Create the application program.
    1. In COBOL program, assign a value to all fields except decimals.
      MOVE LOW-VALUE TO BAD-DATA.
      MOVE 11 TO NORMAL-NUM.
      MOVE 'AAA' TO NORMAL-CHAR.
      MOVE 'BBB' TO NORMAL-CHAR2.
      MOVE 222 TO NORMAL-NUM2.
      MOVE 'CCC' TO NORMAL-CHAR3.
  3. Define CICS resources.
    1. Define and install COBOL program.
    2. Define and install TCPIPSERVICE.
    3. Based on your parser, define and install PIPELINE.
  4. Test the application.
    1. Run PIPELINE SCAN. For the webservice described in the WSbind file, use INSERVICE.
    2. Send the JSON request.
      {"BADDATA1Operation":{"bad_data":{"normal_num":12}}}
    3. Check the response.

Results

Default values are assigned to the uninitialized fields.

{
  "BADDATA1OperationResponse": 
     {
       "bad_data": 
          {
            "normal_num": 11,
            "normal_char": "AAA",
            "pzoned_decimal": 0,
            "nzoned_decima": 0,
            "uzoned_decimal": 0,
            "normal_char2": "BBB",
            "pbinary": 0,
            "nbinary": 0,
            "ubinary": 0,
            "normal_num2": 222,
            "ppacked_decimal": 0,
            "npacked_decimal": 0,
            "upacked_decimal": 0,
            "normal_num3": 0,
            "normal_char3": "CCC",
            "float_zoned": 0,
            "float_packed": 0
            }
       }
}