Page 1 of 1

Returning array from BuildOp

Posted: Mon Nov 09, 2009 5:33 am
by Grace J.
Hi All, I have created a BuildOp stage which needs to return an array value. I need to return the value in date_out4 via the output interface outdata1. How can we return an array from BuildOp to datastage. What datatype we need to mention in datastage for date_out4? I tried like below,

APT_String date_out4[8];
oudata1.date_out4[1]=year1;
oudata1.date_out4[2]=month1;
oudata1.date_out4[3]=day1;

But it is giving error as follows... Please help

Operator Generation Failed

buildop -f -BC /auto/opt/Studio8/SUNWspro/bin/CC -BL /auto/opt/Studio8/SUNWspro/bin/CC -C buildop -H buildop -O buildop -W buildop buildop/date.opd

##E TBLD 000000 Subprocess command failed with exit status 768.
##W TBLD 000000 Output from subprocess: "Per-Record Code (buildop/date.opd)", line 45: Error: The left operand cannot be assigned to.
"Per-Record Code (buildop/date.opd)", line 46: Error: The left operand cannot be assigned to.
"Per-Record Code (buildop/date.opd)", line 47: Error: The left operand cannot be assigned to.
3 Error(s) detected.

##I TBLD 000000 /auto/opt/Studio8/SUNWspro/bin/CC -KPIC -O -I/detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop -I/detld2/etl/ascential/Ascential/DataStage/PXEngine/include -dalign -O -PIC -library=iostream -c /detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop/bosource19638-0.C -o /tmp/bosource19638-0_s.o.

Posted: Mon Nov 09, 2009 5:35 am
by ArndW
What are source lines 40-50, could you post those?

Posted: Mon Nov 09, 2009 5:40 am
by Grace J.
outdata1.date_out4[1]=year1;
outdata1.date_out4[2]=month1;
outdata1.date_out4[3]=day1;

Posted: Mon Nov 09, 2009 5:41 am
by ArndW
And how are these variables declared?

Posted: Mon Nov 09, 2009 5:59 am
by Grace J.
APT_String date_out4[8];
char year1,month1,day1;

Posted: Mon Nov 09, 2009 6:06 am
by ArndW
And how about "oudata1" or is it "outdata1"?

Posted: Mon Nov 09, 2009 6:29 am
by Grace J.
outdata1 only..

outdata1.date_out4[1]=year1;
outdata1.date_out4[2]=month1;
outdata1.date_out4[3]=day1;

Posted: Mon Nov 09, 2009 8:50 am
by Sainath.Srinivasan
Create a character string (say char tempStr[9] ) and store your result there.

Set the date_out4 from this value.

Posted: Tue Nov 10, 2009 12:34 am
by Grace J.
Thank You For Your Reply...I tried as follows...

[b]APT_String date_out4[8],temp[8];
temp[1]=year1;
temp[2]=month1;
temp[3]=day1;
outdata1.date_out4=temp;[/b]

I got the error as follows..

Operator Generation Failed

buildop -f -BC /auto/opt/Studio8/SUNWspro/bin/CC -BL /auto/opt/Studio8/SUNWspro/bin/CC -C buildop -H buildop -O buildop -W buildop buildop/date.opd

##E TBLD 000000 Subprocess command failed with exit status 256.
##W TBLD 000000 Output from subprocess: "Per-Record Code (buildop/date.opd)", line 48: Error: Cannot assign APT_String* to APT_String without "APT_String::operator=(const APT_String&)";.
1 Error(s) detected.

##I TBLD 000000 /auto/opt/Studio8/SUNWspro/bin/CC -KPIC -O -I/detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop -I/detld2/etl/ascential/Ascential/DataStage/PXEngine/include -dalign -O -PIC -library=iostream -c /detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop/bosource26803-0.C -o /tmp/bosource26803-0_s.o.


[b]And I tried as....[/b]

[b]APT_String date_out4[8],temp[8];
temp[1]=year1;
temp[2]=month1;
temp[3]=day1;
outdata1.date_out4[1]=temp[1];
outdata1.date_out4[2]=temp[2];
outdata1.date_out4[3]=temp[3];
writeRecord(0);[/b]

I got the error as...


Operator Generation Failed

buildop -f -BC /auto/opt/Studio8/SUNWspro/bin/CC -BL /auto/opt/Studio8/SUNWspro/bin/CC -C buildop -H buildop -O buildop -W buildop buildop/date.opd

##E TBLD 000000 Subprocess command failed with exit status 768.
##W TBLD 000000 Output from subprocess: "Per-Record Code (buildop/date.opd)", line 48: Error: The left operand cannot be assigned to.
"Per-Record Code (buildop/date.opd)", line 49: Error: The left operand cannot be assigned to.
"Per-Record Code (buildop/date.opd)", line 50: Error: The left operand cannot be assigned to.
3 Error(s) detected.

##I TBLD 000000 /auto/opt/Studio8/SUNWspro/bin/CC -KPIC -O -I/detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop -I/detld2/etl/ascential/Ascential/DataStage/PXEngine/include -dalign -O -PIC -library=iostream -c /detld2/etl/ascential/Ascential/DataStage/Projects/SFB/buildop/bosource28236-0.C -o /tmp/bosource28236-0_s.o.

Any idea of how to return an array value???

Posted: Tue Nov 10, 2009 4:57 am
by Sainath.Srinivasan
What I meant was to use a temporary char variable as below

Code: Select all

char tempStr[9]; // assuming 8 + 1 null

outdata1.date_str4 = tempStr; // direct setting without positional values

Re: Returning array from BuilOp

Posted: Tue Nov 10, 2009 2:32 pm
by Kryt0n
Grace J. wrote: APT_String date_out4[8];
oudata1.date_out4[1]=year1;
oudata1.date_out4[2]=month1;
oudata1.date_out4[3]=day1;
Never having tried a buildop I'm not sure what an APT_String is but guess a char pointer which then asks what are you trying to return, a set of dates or just one date?

If just one date, return just one string and strip it into day/month/year in DS (pretty much what Sainath has suggested).

If a set of dates, then you need to allocate space to the string for each date or assign date_out4 to the address of year1 etc (date_out4 looks to be a pointer, therefore it needs to look at an address not a value).

From what I can see, option 1 is what you are looking for.

(Of course, this is quite likely down to the fact I haven't done a buildop but why have you declared a date_out4 and then attempt to assign a value to oudata1.date_out4?)

Posted: Wed Nov 11, 2009 3:43 am
by Sainath.Srinivasan
Something I noticed after seeing Kryt0n's response....

You are declaring date_out4 but then attempt to set out_data1.date_out4.

They are two different variables.