Take input from two excel and formulate one
This program takes input from two excel sheet and group into one sheet
DEFINE VARIABLE cal AS DECIMAL FORMAT "->>>,999,999.999".
DEFINE VARIABLE cal1 AS DECIMAL FORMAT "->>>,999,999.999".
/*DEFINE VARIABLE site1 LIKE sct_site.*/
DEFINE STREAM tero.
DEFINE TEMP-TABLE ttinv NO-UNDO
FIELD tt_part AS CHARACTER
FIELD tt_qty AS DECIMAL FORMAT "->>>,999,999.999"
FIELD tt_val AS DECIMAL FORMAT "->>>,999,999.999".
DEFINE TEMP-TABLE ttinv1 NO-UNDO
FIELD tttt_part1 AS CHARACTER
FIELD tttt_qty1 AS DECIMAL FORMAT "->>>,999,999.999"
FIELD tttt_val1 AS DECIMAL FORMAT "->>>,999,999.999".
INPUT FROM "C:\Documents and Settings\sachingaur\My Documents\gaur-27\pptrp07.csv".
REPEAT:
CREATE ttinv.
IMPORT DELIMITER "," ttinv.
END.
INPUT CLOSE.
INPUT FROM "C:\Documents and Settings\sachingaur\My Documents\gaur-27\xxinvrep.csv".
REPEAT:
CREATE ttinv1.
IMPORT DELIMITER "," ttinv1.
END.
INPUT CLOSE.
FOR EACH ttinv :
ASSIGN ttinv.tt_part = TRIM(ttinv.tt_part).
IF tt_part = '' THEN DELETE ttinv.
END.
FOR EACH ttinv1 :
ASSIGN tttt_part1 = TRIM(tttt_part1).
IF tttt_part1 = '' THEN DELETE ttinv1.
END.
OUTPUT TO "C:\Documents and Settings\sachingaur\My Documents\gaur-27\FINAL_SHEET.xls".
PUT UNFORMATTED
"Item Number" "~011"
"Quantity1 " "~011"
"Value1" "~011"
"Quantity2" "~011"
"Value2" "~011"
"val1-va12" "~011"
SKIP.
FOR EACH ttinv BREAK BY ttinv.tt_part :
cal = 0.
ACCUMULATE ttinv.tt_qty (TOTAL BY ttinv.tt_part).
ACCUMULATE ttinv.tt_val (TOTAL BY ttinv.tt_part).
IF LAST-OF(ttinv.tt_part) THEN DO:
IF (CAN-FIND(FIRST ttinv1 WHERE ttinv1.tttt_part1 = ttinv.tt_part)) THEN DO:
FOR EACH ttinv1 WHERE ttinv1.tttt_part1 = ttinv.tt_part BREAK BY ttinv1.tttt_part1:
cal1 = 0.
ACCUMULATE ttinv1.tttt_qty1 (TOTAL BY ttinv1.tttt_part1).
ACCUMULATE ttinv1.tttt_val1 (TOTAL BY ttinv1.tttt_part1).
IF LAST-OF(ttinv1.tttt_part1) THEN DO:
cal = ACCUM TOTAL BY ttinv.tt_part ttinv.tt_val.
cal1 = ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_val1.
PUT UNFORMATTED
ttinv.tt_part "~011"
ACCUM TOTAL BY ttinv.tt_part ttinv.tt_qty "~011"
cal /*ACCUM TOTAL BY ttinv.tt_part ttinv.tt_val*/ "~011"
ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_qty1 "~011"
cal1 /*ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_val1*/ "~011"
cal - cal1 "~011"
SKIP.
END.
END.
END.
ELSE DO:
PUT UNFORMATTED
ttinv.tt_part "~011"
ACCUM TOTAL BY ttinv.tt_part ttinv.tt_qty "~011"
ACCUM TOTAL BY ttinv.tt_part ttinv.tt_val "~011"
0 "~011 "
0 "~011"
ACCUM TOTAL BY ttinv.tt_part ttinv.tt_val "~011"
SKIP.
END.
END.
END.
FOR EACH ttinv1 WHERE ttinv1.tttt_part1 <> ' ' break BY ttinv1.tttt_part1 :
DEFINE VARIABLE i AS INTEGER NO-UNDO.
IF (CAN-FIND (FIRST ttinv WHERE ttinv.tt_part = ttinv1.tttt_part1)) THEN
DO:
END.
ELSE DO:
ACCUMULATE ttinv1.tttt_qty1 (TOTAL BY ttinv1.tttt_part1).
ACCUMULATE ttinv1.tttt_val1 (TOTAL BY ttinv1.tttt_part1).
IF LAST-OF(ttinv1.tttt_part1) THEN DO:
PUT UNFORMATTED
ttinv1.tttt_part1 "~011"
0 "~011"
0 "~011"
ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_qty1 "~011"
ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_val1 "~011"
0 - ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_val1 "~011"
SKIP.
END.
END.
END.
OUTPUT CLOSE.
DEFINE VARIABLE cal AS DECIMAL FORMAT "->>>,999,999.999".
DEFINE VARIABLE cal1 AS DECIMAL FORMAT "->>>,999,999.999".
/*DEFINE VARIABLE site1 LIKE sct_site.*/
DEFINE STREAM tero.
DEFINE TEMP-TABLE ttinv NO-UNDO
FIELD tt_part AS CHARACTER
FIELD tt_qty AS DECIMAL FORMAT "->>>,999,999.999"
FIELD tt_val AS DECIMAL FORMAT "->>>,999,999.999".
DEFINE TEMP-TABLE ttinv1 NO-UNDO
FIELD tttt_part1 AS CHARACTER
FIELD tttt_qty1 AS DECIMAL FORMAT "->>>,999,999.999"
FIELD tttt_val1 AS DECIMAL FORMAT "->>>,999,999.999".
INPUT FROM "C:\Documents and Settings\sachingaur\My Documents\gaur-27\pptrp07.csv".
REPEAT:
CREATE ttinv.
IMPORT DELIMITER "," ttinv.
END.
INPUT CLOSE.
INPUT FROM "C:\Documents and Settings\sachingaur\My Documents\gaur-27\xxinvrep.csv".
REPEAT:
CREATE ttinv1.
IMPORT DELIMITER "," ttinv1.
END.
INPUT CLOSE.
FOR EACH ttinv :
ASSIGN ttinv.tt_part = TRIM(ttinv.tt_part).
IF tt_part = '' THEN DELETE ttinv.
END.
FOR EACH ttinv1 :
ASSIGN tttt_part1 = TRIM(tttt_part1).
IF tttt_part1 = '' THEN DELETE ttinv1.
END.
OUTPUT TO "C:\Documents and Settings\sachingaur\My Documents\gaur-27\FINAL_SHEET.xls".
PUT UNFORMATTED
"Item Number" "~011"
"Quantity1 " "~011"
"Value1" "~011"
"Quantity2" "~011"
"Value2" "~011"
"val1-va12" "~011"
SKIP.
FOR EACH ttinv BREAK BY ttinv.tt_part :
cal = 0.
ACCUMULATE ttinv.tt_qty (TOTAL BY ttinv.tt_part).
ACCUMULATE ttinv.tt_val (TOTAL BY ttinv.tt_part).
IF LAST-OF(ttinv.tt_part) THEN DO:
IF (CAN-FIND(FIRST ttinv1 WHERE ttinv1.tttt_part1 = ttinv.tt_part)) THEN DO:
FOR EACH ttinv1 WHERE ttinv1.tttt_part1 = ttinv.tt_part BREAK BY ttinv1.tttt_part1:
cal1 = 0.
ACCUMULATE ttinv1.tttt_qty1 (TOTAL BY ttinv1.tttt_part1).
ACCUMULATE ttinv1.tttt_val1 (TOTAL BY ttinv1.tttt_part1).
IF LAST-OF(ttinv1.tttt_part1) THEN DO:
cal = ACCUM TOTAL BY ttinv.tt_part ttinv.tt_val.
cal1 = ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_val1.
PUT UNFORMATTED
ttinv.tt_part "~011"
ACCUM TOTAL BY ttinv.tt_part ttinv.tt_qty "~011"
cal /*ACCUM TOTAL BY ttinv.tt_part ttinv.tt_val*/ "~011"
ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_qty1 "~011"
cal1 /*ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_val1*/ "~011"
cal - cal1 "~011"
SKIP.
END.
END.
END.
ELSE DO:
PUT UNFORMATTED
ttinv.tt_part "~011"
ACCUM TOTAL BY ttinv.tt_part ttinv.tt_qty "~011"
ACCUM TOTAL BY ttinv.tt_part ttinv.tt_val "~011"
0 "~011 "
0 "~011"
ACCUM TOTAL BY ttinv.tt_part ttinv.tt_val "~011"
SKIP.
END.
END.
END.
FOR EACH ttinv1 WHERE ttinv1.tttt_part1 <> ' ' break BY ttinv1.tttt_part1 :
DEFINE VARIABLE i AS INTEGER NO-UNDO.
IF (CAN-FIND (FIRST ttinv WHERE ttinv.tt_part = ttinv1.tttt_part1)) THEN
DO:
END.
ELSE DO:
ACCUMULATE ttinv1.tttt_qty1 (TOTAL BY ttinv1.tttt_part1).
ACCUMULATE ttinv1.tttt_val1 (TOTAL BY ttinv1.tttt_part1).
IF LAST-OF(ttinv1.tttt_part1) THEN DO:
PUT UNFORMATTED
ttinv1.tttt_part1 "~011"
0 "~011"
0 "~011"
ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_qty1 "~011"
ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_val1 "~011"
0 - ACCUM TOTAL BY ttinv1.tttt_part1 ttinv1.tttt_val1 "~011"
SKIP.
END.
END.
END.
OUTPUT CLOSE.
Comments