This is a very light version of my program. I remove a lot of stuff that is useless to the comprehension of the problem. The program have to generates a report of cashing for every bank. In the infile, there are 2 types of record G : The positive amounts of money H : The negative amounts of money So, I have to sort these records by type, bank_id, reference_id. I need to make a total for every bank. The totals of the types are already calculated and I recuperate theirs values via macro variables. At first, I print and make totals for the G records. After, I made totals for the H records. Also, I give you some explications about the variable cause theirs names are in french and maybe you're not going to understand TOTAL_ENCAISSEMENTS_CAISSE, TOTAL_FRAIS_ENCAISSEMENTS_CAISSE : Variables I use to conserve the bank totals MONTANT_REEL, FRAIS_REEL : Variables that contain the monetary data of the current record NO_REF : That's the reference_id NO_CAISSE2 : That's the formatted bank_id DATA AA; FILE RAPPORT; FORMAT TOTAL_ENCAISSEMENTS_CAISSE COMMA19.2; FORMAT TOTAL_FRAIS_ENCAISSEMENTS_CAISSE COMMA14.2; FORMAT SOMME_ENC_FORMAT COMMA19.2; FORMAT SOMME_CORRECTIONS_FORMAT COMMA19.2; FORMAT SOMME_FRAIS_FORMAT COMMA14.2; RETAIN NO_REF NO_CAISSE2 TOTAL_ENCAISSEMENTS_CAISSE, TOTAL_FRAIS_ENCAISSEMENTS_CAISSE, SOMME_ENC_FORMAT; SET DESJARD END=EOF; BY TYPE NO_CAISSE NO_REF; IF _N_ = 1 THEN DO; TOTAL_ENCAISSEMENTS_CAISSE =0; // Print the report column header END; SELECT (TYPE); WHEN ('G', 'H') DO; // Print the current record FRAIS_ENC_TEMP = SUM(TOTAL_ENCAISSEMENTS_CAISSE,MONTANT_REEL); TOTAL_FRAIS_ENCAISSEMENTS_CAISSE = SUM (TOTAL_FRAIS_ENCAISSEMENTS_CAISSE, FRAIS_REEL); IF LAST.NO_CAISSE THEN DO; // It's the last record of this bank, so I print totals and I want to initialize the variables for the next bank. PUT @045 FRAIS_ENC_TEMP COMMA19.2 @064 TOTAL_FRAIS_ENCAISSEMENTS_CAISSE COMMA15.2; TOTAL_ENCAISSEMENTS_CAISSE = 0; TOTAL_FRAIS_ENCAISSEMENTS_CAISSE = 0; FRAIS_REEL = 0; END; IF LAST.TYPE THEN DO; IF (TYPE='G') THEN DO; // Positive numbers SOMME_ENC_FORMAT = INPUT("&SOMME_ENCAISSEMENTS.",COMMA19.2); PUT @045 SOMME_ENC_FORMAT COMMA19.2 @064 "&SOMME_FRAIS_ENCAISSEMENT."; END; ELSE IF (TYPE='H') THEN DO; // Negative numbers SOMME_CORRECTIONS_FORMAT = INPUT("&SOMME_CORRECTIONS.",19.2) * -1; SOMME_FRAIS_FORMAT = INPUT("&SOMME_FRAIS_CORRECTION.",12.2) * -1; PUT @046 SOMME_CORRECTIONS_FORMAT COMMA19.2 @064 SOMME_FRAIS_FORMAT COMMA15.2; END; END; ELSE DO; TOTAL_ENCAISSEMENTS_CAISSE = SUM(TOTAL_ENCAISSEMENTS_CAISSE,MONTANT_REEL); TOTAL_FRAIS_ENCAISSEMENTS_CAISSE = SUM(TOTAL_FRAIS_ENCAISSEMENTS_CAISSE,FRAIS_REEL); END; END; OTHERWISE; END;
... View more