here is the code i have for the task at hand. Does this look good? Mike thanks for all the help!!!!!... All i will need to do is uncomment the buffer copy. Please let me know this the first time i have done anything in progress.
DEF VAR itmchng AS CHAR FORMAT "x(2)".
DEF VAR iixcheck AS CHAR FORMAT "X(26)".
DEF VAR iixunit1 AS CHAR FORMAT "X(4)".
DEF VAR iixunit2 AS CHAR FORMAT "X(4)".
Def var itmcode as char format "X(26)".
Def var iibcode as char format "X(26)".
def var bmqcode as char format "X(26)".
DEF VAR iixratio AS DECIMAL FORMAT "zz,zzz,zz9.9999".
/* change the variable below to what ever is desired or needed to chane */
itmchng = '07'.
/* DEFINE BUFFER iix-out for iix.*/
FOR EACH iix WHERE SUBSTRING(iix.item-code,1,2) = itmchng AND iix.item-unit[2] > "" and iix.active-flg > "" No-Lock:
/* BUFFER-COPY iix to iix-out
Assign
iix-out.item-code = "1" + SUBSTRING(iix.item-code,2).
iix-out.item-unit[2] = iix.item-unit[1].
iix-out.item-unit[1] = iix.item-unit[2].
iix-out.item-ratio[2] = (1 / iix.unit-ratio[2]). */
iixcheck = "1" + SUBSTRING(iix.item-code,2).
iixunit1 = iix.item-unit[2].
iixunit2 = iix.item-unit[1].
iixratio = (1 / iix.unit-ratio[2]).
DISPLAY iixcheck.
DISPLAY iixunit1.
DISPLAY iixunit2.
DISPLAY iixratio.
END. /* FOR EACH iix: */
/* ITM table joined with iix table*/
/* DEFINE BUFFER itm-out for itm.*/
for each itm,
EACH iix WHERE iix.item-code = itm.item-code AND SUBSTRING(iix.item-code,1,2) = itmchng AND iix.active-flg > "" AND iix.item-unit[2] > "" NO-LOCK:
/* BUFFER-COPY itm to itm-out
item-out.itm-code = "1" + SUBSTRING(itm.item-code,2).*/
itmcode = "1" + SUBSTRING(itm.item-code,2).
display itmcode.
end. /*for each itm:*/
/* iib table joined with iix*/
/* DEFINE BUFFER iib-out for iib. */
for each iib,
EACH iix WHERE iix.item-code = iib.item-code AND SUBSTRING(iix.item-code,1,2) = itmchng AND iix.active-flg > "" AND iix.item-unit[2] > "" AND iib.active-flg > "" NO-LOCK:
/* BUFFER-COPY iib to iib-out
iib-out.item-code = "1" + SUBSTRING(iib.item-code,2).*/
iibcode = "1" + SUBSTRING(iib.item-code,2).
display iibcode.
end. /* for each iib. */
/* bmq table joined with iix*/
/*DEFINE BUFFER bmq-out for bmq.*/
for each bmq,
EACH iix WHERE iix.item-code = bmq.item-code AND SUBSTRING(iix.item-code,1,2) = itmchng AND iix.active-flg > "" AND iix.item-unit[2] > "" NO-LOCK:
/* BUFFER-COPY bmq to bmq-out
bmq-out.item-unit = "1" + SUBSTRING(bmq.item-code,2).*/
bmqcode = "1" + SUBSTRING(bmq.item-code,2).
display bmqcode.
End. /* for each bmq. */
DEF VAR itmchng AS CHAR FORMAT "x(2)".
DEF VAR iixcheck AS CHAR FORMAT "X(26)".
DEF VAR iixunit1 AS CHAR FORMAT "X(4)".
DEF VAR iixunit2 AS CHAR FORMAT "X(4)".
Def var itmcode as char format "X(26)".
Def var iibcode as char format "X(26)".
def var bmqcode as char format "X(26)".
DEF VAR iixratio AS DECIMAL FORMAT "zz,zzz,zz9.9999".
/* change the variable below to what ever is desired or needed to chane */
itmchng = '07'.
/* DEFINE BUFFER iix-out for iix.*/
FOR EACH iix WHERE SUBSTRING(iix.item-code,1,2) = itmchng AND iix.item-unit[2] > "" and iix.active-flg > "" No-Lock:
/* BUFFER-COPY iix to iix-out
Assign
iix-out.item-code = "1" + SUBSTRING(iix.item-code,2).
iix-out.item-unit[2] = iix.item-unit[1].
iix-out.item-unit[1] = iix.item-unit[2].
iix-out.item-ratio[2] = (1 / iix.unit-ratio[2]). */
iixcheck = "1" + SUBSTRING(iix.item-code,2).
iixunit1 = iix.item-unit[2].
iixunit2 = iix.item-unit[1].
iixratio = (1 / iix.unit-ratio[2]).
DISPLAY iixcheck.
DISPLAY iixunit1.
DISPLAY iixunit2.
DISPLAY iixratio.
END. /* FOR EACH iix: */
/* ITM table joined with iix table*/
/* DEFINE BUFFER itm-out for itm.*/
for each itm,
EACH iix WHERE iix.item-code = itm.item-code AND SUBSTRING(iix.item-code,1,2) = itmchng AND iix.active-flg > "" AND iix.item-unit[2] > "" NO-LOCK:
/* BUFFER-COPY itm to itm-out
item-out.itm-code = "1" + SUBSTRING(itm.item-code,2).*/
itmcode = "1" + SUBSTRING(itm.item-code,2).
display itmcode.
end. /*for each itm:*/
/* iib table joined with iix*/
/* DEFINE BUFFER iib-out for iib. */
for each iib,
EACH iix WHERE iix.item-code = iib.item-code AND SUBSTRING(iix.item-code,1,2) = itmchng AND iix.active-flg > "" AND iix.item-unit[2] > "" AND iib.active-flg > "" NO-LOCK:
/* BUFFER-COPY iib to iib-out
iib-out.item-code = "1" + SUBSTRING(iib.item-code,2).*/
iibcode = "1" + SUBSTRING(iib.item-code,2).
display iibcode.
end. /* for each iib. */
/* bmq table joined with iix*/
/*DEFINE BUFFER bmq-out for bmq.*/
for each bmq,
EACH iix WHERE iix.item-code = bmq.item-code AND SUBSTRING(iix.item-code,1,2) = itmchng AND iix.active-flg > "" AND iix.item-unit[2] > "" NO-LOCK:
/* BUFFER-COPY bmq to bmq-out
bmq-out.item-unit = "1" + SUBSTRING(bmq.item-code,2).*/
bmqcode = "1" + SUBSTRING(bmq.item-code,2).
display bmqcode.
End. /* for each bmq. */