Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

import into tables buffer Look Good?

Status
Not open for further replies.

spoye

Programmer
Nov 5, 2009
8
US
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. */
 
Looks pretty good, except you left out the ASSIGN keyword in the itm, iib, and bmq BUFFER-COPY statements. My personal preference would have been to enclose the itm, iib, and bmq FOR EACH blocks within the iix FOR EACH block, but if your joins work, it's all good.

You should be able to find a 'check syntax' function in your coding environment to make sure your code will compile OK before you hit that RUN key.

Best of luck to ya'.
 
thank you for all the help!! I ran the check sytax and all is well!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top