SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

IMS DL/I query

Reply
New Contributor
Posts: 3

IMS DL/I query

Hi everyone,

Sorry if this question is not in the correct part of the forum but I am using SAS on an IBM Mainframe (z/OS) and want to query an IMS database. I can query a certain segment and a child segment within one DATA step but I am having trouble querying a child segment of the child segment (level 3).

My data step reading 2 levels which works

DATA SET1;

LENGTH SSA1 $45.;

LENGTH CFUNC $4.;

LENGTH ST $2;

INFILE PSB1 DLI CALL=CFUNC SSA=SSA1 STATUS=ST PCB=1 LRECL=1600;

CFUNC = 'GN  ';

SSA1 = 'SEG1NAME';

INPUT @;

IF ST = 'GE' THEN STOP;

INPUT @1  KEYLVL1  $10.;

ST = ' ';

DO WHILE (ST = ' ');

CFUNC = 'GNP ';

SSA1 = 'SEG2NAME';

INPUT @;

IF ST = ' ' THEN DO;

INPUT @1 DATALVL2 $30;

OUTPUT;

ST = ' ';

_ERROR_ = 0;

END;

END;

But if I alter this to try to go 3 levels deep

DATA SET2;

LENGTH SSA1 $45.;

LENGTH CFUNC $4.;

LENGTH ST $2;

INFILE PSB1 DLI CALL=CFUNC SSA=SSA1 STATUS=ST PCB=1 LRECL=1600;

CFUNC = 'GN  ';

SSA1 = 'SEG1NAME';

INPUT @;

IF ST = 'GE' THEN STOP;

INPUT @1  KEYLVL1  $10.;

ST = ' ';

DO WHILE (ST = ' ');

CFUNC = 'GNP ';

SSA1 = 'SEG2NAME';

INPUT @;

IF ST = ' ' THEN DO;

INPUT @1 DATALVL2 $30.;

ST = ' ';

DO WHILE (ST = ' ');

CFUNC = 'GNP ';

SSA1 = 'SEG3NAME';

INPUT @;

IF ST = ' ' THEN DO;

INPUT @1 DATALVL3 $40.;

OUTPUT;

END:

ST = ' ';

_ERROR_ = 0;

END;

END;

it reads segment 1 OK, then the first child 'record' of segment 2 then loops through all the segment 3 'records' belonging to segment 1 (some of which belong to other segment 2 'records'). I have tried different call functions and tried having multiple qualified SSAs and get different results, but I cannot loop through each segment 2 record one by one reading all segment 3 records. I am wondering if it is possible, within one data step, to read N levels down in a IMS database.

Hope this make some sense.

Mark.

Ask a Question
Discussion stats
  • 0 replies
  • 163 views
  • 0 likes
  • 1 in conversation