Help needed for dumping the Alternate Unit of Measurement

Namasiva

Member
Hi

I try to dump the Alternate Unit of Measures in a file.

I created the following program.
but the output is not correct.
For instance item number 017299 gives following output.
017299;22+03+11;Contec;OK;1;1;.001;1;10;5;6;1000;1;1;001;
For this item the alternate UM DU is not available but it display as 1.
this happened for most of the items.
Can you look what i did wrong in my script



++++++++++++++++++++++++++++++++++++++++++++++++++++++++

{mfdtitle.i "XX a"}
def var file as cha no-undo form "x(20)" init "altum.xls".
def var dir as cha no-undo form "x(20)"
init "./".

def var t1_part like um_part.
def var t1_umum like um_um.
def var t1_umaltum like um_alt_um.
def var t1_umconvdu like um_conv init "".
def var t1_umconvcs like um_conv init "".
def var t1_umconvpc like um_conv init "".
def var t1_umconvkg like um_conv init "".
def var t1_umconvlt like um_conv init "".
def var t1_umconvhi like um_conv init "".
def var t1_umconvti like um_conv init "".
def var t1_umconvpl like um_conv init "".
def var t1_umconvst like um_conv init "".
def var t1_umconvsu like um_conv init "".
def stream x.
def temp-table t1_altum no-undo
field t1_part like pt_part
field t1_umum like um_um
field t1_umaltum like um_alt_um
field t1_umconvdu like um_conv
field t1_umconvcs like um_conv
field t1_umconvpc like um_conv
field t1_umconvkg like um_conv
field t1_umconvlt like um_conv
field t1_umconvhi like um_conv
field t1_umconvti like um_conv
field t1_umconvpl like um_conv
field t1_umconvst like um_conv
field t1_umconvsu like um_conv.

form "Download Alternate Product UM data in file to user directory
filename : " file no-label skip
with frame a width 80 side-labels.
display file with frame a.

assign dir = "./".
assign bcdparm = "".

{mfselbpr.i printer 80}
{mfphead2.i}
pause 0 before-hide.
output stream x to value(dir + file).
put stream x
"Product;Desc1;Desc2;DU;"
"CS;PC;KG;LT;HI;TI;PL;ST;SU;"
skip.

for each pt_mstr where pt_domain = global_domain
no-lock:
for each um_mstr where um_domain = global_domain
and um_part = pt_part
and um_um = pt_um
no-lock
break by um_part by um_alt_um:

if um_alt_um = "DU"
then assign t1_umconvdu = um_conv.
if um_alt_um = "CS"
then assign t1_umconvcs = um_conv.
if um_alt_um = "PC"
then assign t1_umconvpc = um_conv.
if um_alt_um = "KG"
then assign t1_umconvkg = um_conv.
if um_alt_um = "LT"
then assign t1_umconvlt = um_conv.
if um_alt_um = "HI"
then assign t1_umconvhi = um_conv.
if um_alt_um = "TI"
then assign t1_umconvti = um_conv.
if um_alt_um = "PL"
then assign t1_umconvpl = um_conv.
if um_alt_um = "ST"
then assign t1_umconvst = um_conv.
if um_alt_um = "SU"
then assign t1_umconvsu = um_conv.
if last-of (um_part) then
put stream x unformatted
um_part ";"
pt_desc1 ";"
pt_desc2 ";"
pt_status ";"
string(t1_umconvdu) ";"
/* t1_umconvdu ";" */
t1_umconvcs ";"
t1_umconvpc ";"
t1_umconvkg ";"
t1_umconvlt ";"
t1_umconvhi ";"
t1_umconvti ";"
t1_umconvpl ";"
t1_umconvst ";"
t1_umconvsu ";"
um_domain ";"
skip.
end.
end.
output stream x close.
pause before-hide.
{mftrl080.i}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Thanks for your Help.
 
Nothing is wrong with your program, did you view your output in EXCEL? if yes then its fornatting reqd in Excel, see it in wordpad.
 

Namasiva

Member
Hi Chari,

Thanks for your reply.

even though if i open it in Word pad, i am getting the same format and its displaying more than one line (as below)

017299;22+03+11;Contec;OK;.001;1;.001;1;10;5;6;30;1;1;001;
017299;22+03+11;Contec;OK;1000;1;.001;1;10;5;6;1000;1;1;001;
017299;22+03+11;Contec;OK;1;1;.001;1;10;5;6;1000;1;1;001;
017299;22+03+11;Contec;OK;1;1;.001;1;10;5;6;1000;1;1;001;


Please help me out to resolve this issue.

Thanks in advance
 

Namasiva

Member
Hello sir,

Thank you once againg for your reply

The below are the Alternate UM defined in our system we haven't defined any "DU" , "CS" as alternate UM but here in my report it displaying some value, which is wrong.

│Item Number Output │
017299 22+03+11 terminal │
└──────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────┐
│Item Number Description BuM Alt UM Conv │
│────────────────── ──────────────────────── ─── ─── ────────── │
│017299 22+03+11 00 KG 1.0000 │
│017299 22+03+11 00 PC 0.0010 │
│017299 22+03+11 00 pl 1000.0000 │
│017299 22+03+11 00 ST 1.0000 │
│017299 22+03+11 00 SU 1.0000 │
│ │

if the alternate um is not defined then it has to display "0".

Please help me out.

Once againg thanks for your support.
 

Namasiva

Member
Hi chari,

Thanks again for your reply, now the lines printing more than one time is stopped but some of the item it took uom_conv as "0" see below in Red,
but for some item its not working. i am confused what should i do?


Product;Desc1;Desc2;Status;DU;CS;PC;KG;LT;HI;TI;PL;ST;SU;

0016997;Colour Pro Turf Spray;Indicator Dye;NPR;0;1;4;6;20;4;10;40;1;1;001;

010894;Cascade Applicator;Applicators;FADE OUT;0;1;4;4;20;4;10;40;1;1;001;


Please Pease help me!..
 

Namasiva

Member
Hi chari,

Thanks again for your reply, now the lines printing more than one time is stopped but some of the item it took uom_conv as "0" see below in Red,
but for some item its not working. i am confused what should i do?


Product;Desc1;Desc2;Status;DU;CS;PC;KG;LT;HI;TI;PL;ST;SU;

0016997;Colour Pro Turf Spray;Indicator Dye;NPR;0;1;4;6;20;4;10;40;1;1;001;

010894;Cascade Applicator;Applicators;FADE OUT;0;1;4;4;20;4;10;40;1;1;001;


Please Please help me!..
 

Namasiva

Member
Hi Chari,

Thanks for all your help. The problem is now solved with below code.
def var file as cha no-undo form "x(20)" init "altum.xls".
def var dir as cha no-undo form "x(20)"
init "./".

def var t1_part like um_part.
def var t1_umum like um_um.
def var t1_umaltum like um_alt_um.
def var convdu as dec init 0.
def var convcs as dec init 0.
def var convpc as dec init 0.
def var convkg as dec init 0.
def var convlt as dec init 0.
def var convhi as dec init 0.
def var convti as dec init 0.
def var convpl as dec init 0.
def var convst as dec init 0.
def var convsu as dec init 0.


def stream x.

def temp-table t1_altum no-undo
field t1_part like pt_part
field t1_umum like um_um
field t1_umaltum like um_alt_um
field t1_umconvdu as dec
field t1_umconvcs as dec
field t1_umconvpc as dec
field t1_umconvkg as dec
field t1_umconvlt as dec
field t1_umconvhi as dec
field t1_umconvti as dec
field t1_umconvpl as dec
field t1_umconvst as dec
field t1_umconvsu as dec.

form "Download Alternate Product UM data in file to user directory
filename : " file no-label skip


with frame a width 80 side-labels.
display file with frame a.

assign dir = "./".
/*assign bcdparm = "". */


for each t1_altum:
delete t1_altum.
end.


/* {mfselbpr.i printer 80} */
/* {mfphead2.i} */
pause 0 before-hide.
output stream x to value(dir + file).
put stream x
"Product;Desc1;Desc2;Status;DU;"
"CS;PC;KG;LT;HI;TI;PL;ST;SU;"
skip.

for each pt_mstr where pt_domain = "001"
/*and pt_part > "017600" and
pt_part < "20940302XA/W66" */
no-lock: /* break by pt_part: */


/* if last-of (pt_part) then do: */

find um_mstr where
um_domain = "001" and /*082206*/
um_um = pt_um
and um_alt_um = "du"
and um_part = pt_part
no-lock no-error .
assign convdu = if available um_mstr then um_conv
else 0.


find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "cs"
and um_part = pt_part
no-lock no-error.
assign convcs = if available um_mstr then 1 / um_conv
else 0.

find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "pc" /*022808*/
and um_part = pt_part
no-lock no-error.
assign convpc = if available um_mstr then um_conv
else 0.

find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "kg"
and um_part = pt_part
no-lock no-error.
assign convkg = if available um_mstr then um_conv
else 0.


find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "lt"
and um_part = pt_part
no-lock no-error.
assign convlt = if available um_mstr then um_conv
else 0.

find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "hi"
and um_part = pt_part
no-lock no-error.
assign convhi = if available um_mstr then um_conv
else 0.

find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "ti"
and um_part = pt_part
no-lock no-error.
assign convti = if available um_mstr then um_conv
else 0.

find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "pl"
and um_part = pt_part
no-lock no-error.
assign convpl = if available um_mstr then um_conv
else 0.

find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "st"
and um_part = pt_part
no-lock no-error.
assign convst = if available um_mstr then um_conv
else 0.
find um_mstr where
um_domain = "001" and
um_um = pt_um
and um_alt_um = "su"
and um_part = pt_part
no-lock no-error.
assign convsu = if available um_mstr then um_conv
else 0.


find t1_altum where t1_part = pt_part no-error.
if not available t1_altum then do:
create t1_altum.
assign t1_part = pt_part
t1_umconvdu = convdu
t1_umconvcs = convcs
t1_umconvpc = convpc
t1_umconvkg = convkg
t1_umconvlt = convlt
t1_umconvhi = convhi
t1_umconvti = convti
t1_umconvpl = convpl
t1_umconvst = convst
t1_umconvsu = convsu.

put stream x unformatted
t1_part "~011"
pt_desc1 "~011"
pt_desc2 "~011"
pt_status "~011"
t1_umconvdu "~011"
t1_umconvcs "~011"
t1_umconvpc "~011"
t1_umconvkg "~011"
t1_umconvlt "~011"
t1_umconvhi "~011"
t1_umconvti "~011"
t1_umconvpl "~011"
t1_umconvst "~011"
t1_umconvsu "~011"
skip.
end.
end.
output stream x close.


Thanks.
 
Top