Hi Buddy,
I have one logic which is retrieving the content from mutiple files dynamically using "INFILE MYINFILE FILEVAR=dsn FILENAME=MYINFILE END=nd; " statement. For some cases the below code doesn't ran fine. I don't know the exact problem in the below code. I took the backup of the input files and ran with this code. For this the code ran fine. Please help to find the bug in the below code.
Sorce code:-
DATA main(KEEP=clientno date year)
adset(KEEP=client process align subset date year)
adjust(KEEP=client process_id ip_rows op_rows comment1 type date year)
drm45(KEEP=client process date comment) ;
SET one NOBS=n1;
FORMAT date DATE5. ;
len = LENGTH(dsn) ;
date = SUBSTR(dsn,len-6,3);
CALL SYMPUT('date',PUT(date,DATE5.));
year=TRIM("&year4");
IF n1 >= _N_ THEN DO;
INFILE MYINFILE FILEVAR=dsn FILENAME=MYINFILE END=nd;
IF nd ¬=1 THEN DO;
subject=' '; process=' ';
proces1=' ';
INPUT @1 subject $7.
@10 process $5.
@10 proces1 $14. ;
put subject= process= proces1=;
****************************************************************;
*** Reading Data for Adset process Email notification *****;
****************************************************************;
IF process = 'ADSET' THEN DO;
INPUT / @1 status $80.
/ @17 client $3.
/ @17 align $1.
/ @17 subset $2.;
PUT 'INSIDE ADSET: ' _n_ ;
OUTPUT adset;
END;
****************************************************************;
*** Reading Data for DRM45 process Email notification *****;
****************************************************************;
IF process = 'DRM45' THEN DO;
INPUT / @1 status $80.
/ @20 client $3.;
IF TRIM(SUBSTR(status,18,6)) = "FAILED" THEN
comment = 'ERROR ENCOUNTERED' ;
ELSE DO ;
INPUT / / / @1 rec3 $80. ;
IF INDEX(rec3,'NOT PROCESSED') ¬= 0 THEN
comment = 'ERROR ENCOUNTERED' ;
ELSE
comment = '' ;
END;
PUT 'INSIDE DRM45: ' _N_ ;
OUTPUT drm45;
END;
****************************************************************;
*** Reading Data for Adjustment set Email notification *****;
****************************************************************;
IF proces1 = "ADJUSTMENT SET" THEN DO;
comment1 = ' ';
DO UNTIL(nd);
RETAIN comment1 client process_id ip_rows op_rows;
put comment1= client= process_id= ;
INPUT @1 rec $140.;
IF INDEX(rec,'CLIENT ID') ¬= 0 THEN
client = SUBSTR(rec,18,3);
IF INDEX(rec,'PROCESS ID') ¬= 0 THEN
process_id = SUBSTR(rec,19,7);
IF INDEX(rec,'READ') ¬= 0 THEN
ip_rows = SUBSTR(rec,55,10);
IF INDEX(rec,'WRITTEN') ¬= 0 THEN
op_rows = SUBSTR(rec,55,10);
IF INDEX(rec,'ERRORS') ¬= 0 THEN
comment1 = 'ERROR ENCOUNTERED';
END ;
IF nd = 1 THEN OUTPUT adjust;
END ;
put ' end of adjustment';
****************************************************************;
*** Reading Data for PRH10 process Email notification *****;
****************************************************************;
IF subject = 'DATA' THEN DO;
put ' DATA';
DO UNTIL(nd);
INPUT @1 keyword1 $6.
@42 clientno $3. ;
IF keyword1 = 'CLIENT' THEN OUTPUT main;
END ;
END ;
END;
END;
RUN;