I am looking for a script which is able to count the occurences of "fields" (startpos, length) with a specific values in a dataset. So far I developed the following solution.
I am using the COPY-Command to extract all matching fields plus a counting var into a temporary dataset. In a second step i sum the counter var.
COPY FROM(INLOW) TO(TMPLOW) -
USING(AA10)
COPY FROM(INLOW) TO(TMPLOW) -
USING(AA11)
//AA10CNTL DD *
OUTREC BUILD=(1:C'000000000001',
13:C':FIELD_TEST1:',
26:1,1,
37:C' ')
INCLUDE COND=(1,1,CH,EQ,C' ')
/*
//AA11CNTL DD *
OUTREC BUILD=(1:C'000000000001',
13:C':FIELDTEST:',
24:2,3,
37:C' ')
INCLUDE COND=(2,3,CH,EQ,C' ')
/*
USING(AA10)
COPY FROM(INLOW) TO(TMPLOW) -
USING(AA11)
//AA10CNTL DD *
OUTREC BUILD=(1:C'000000000001',
13:C':FIELD_TEST1:',
26:1,1,
37:C' ')
INCLUDE COND=(1,1,CH,EQ,C' ')
/*
//AA11CNTL DD *
OUTREC BUILD=(1:C'000000000001',
13:C':FIELDTEST:',
24:2,3,
37:C' ')
INCLUDE COND=(2,3,CH,EQ,C' ')
/*
This works but with extremely poor performance, because for every condition a copy task is required. I would like to perform all the conditions in one CNTL. For instance (psydocode):
//AA10CNTL DD *
IF INCLUDE COND=(1,1,CH,EQ,C' ') THEN
OUTREC BUILD=(1:C'000000000001',
13:C':FIELD_TEST1:',
26:1,1,
37:C' ')
END IF
IF INCLUDE COND=(2,3,CH,EQ,C' ') THEN
OUTREC BUILD=(1:C'000000000001',
13:C':FIELDTEST:',
24:2,3,
37:C' ')
END IF
/*
IF INCLUDE COND=(1,1,CH,EQ,C' ') THEN
OUTREC BUILD=(1:C'000000000001',
13:C':FIELD_TEST1:',
26:1,1,
37:C' ')
END IF
IF INCLUDE COND=(2,3,CH,EQ,C' ') THEN
OUTREC BUILD=(1:C'000000000001',
13:C':FIELDTEST:',
24:2,3,
37:C' ')
END IF
/*
Unfortunately i don't know the correct sytax for this psydo code .
Thanks a lot for your help in advance and best regards!