Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Subroutine in Load with Call

Hi to all,

I need to do a unit measure conversion, starting from a fact table and convert the qty from "original UM" to "destination UM".

Instead of convert it using a big formula inside the load I wanted to use a subroutine.

It works but I can't use the call inside a load.

I attach my example.

Any idea to do it with the subroutine or different solution for the same problem without doing all the calculation inside the load ?

Thanks

Sergio

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The Call does not return a value, so you can't use it like that.

I suggest that you do a load like this


Data:
LOAD UM,
MATE,
QTY * ConverOrig / ConverDesti AS QtyConv,
QTY,
TO;
LOAD *,
subfield(ApplyMap('ConversionMap',MATE & UM,' '),';',1) / subfield(ApplyMap('ConversionMap',MATE & UM,' '),';',2) AS ConverOrig,
subfield(ApplyMap('ConversionMap',MATE & 'CS',' '),';',1) / subfield(ApplyMap('ConversionMap',MATE & 'CS',' '),';',2) AS ConverDesti;
LOAD UM,
MATE,
(Call Convert(MATE,UM,'CS',QTY)) as QtyConv,
QTY,
TO
RESIDENT DataTmp;



Just check that I converted the two subfield lines correctly.

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

5 Replies
Not applicable
Author

Hi Anyone found a way to solve the issue in an easy way ?

Thanks

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The Call does not return a value, so you can't use it like that.

I suggest that you do a load like this


Data:
LOAD UM,
MATE,
QTY * ConverOrig / ConverDesti AS QtyConv,
QTY,
TO;
LOAD *,
subfield(ApplyMap('ConversionMap',MATE & UM,' '),';',1) / subfield(ApplyMap('ConversionMap',MATE & UM,' '),';',2) AS ConverOrig,
subfield(ApplyMap('ConversionMap',MATE & 'CS',' '),';',1) / subfield(ApplyMap('ConversionMap',MATE & 'CS',' '),';',2) AS ConverDesti;
LOAD UM,
MATE,
(Call Convert(MATE,UM,'CS',QTY)) as QtyConv,
QTY,
TO
RESIDENT DataTmp;



Just check that I converted the two subfield lines correctly.

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Great !

I didn't know I could use this way to reload data and so to use precalculated variables

Thanks

Sergio

wizardo
Creator III
Creator III

hi there Jonathan,

iv read this tread and it seems i am missing something in the code you suggested.

where is the table "DataTmp" that you are Resident loading from?

where is the definition of the Mapping table "ConversionMap"?

and can you please explain how you are using the CALL coomand inside a load statement.

thanks for your time

Mansyno

jonathandienst
Partner - Champion III
Partner - Champion III

Mansyno

This was posted some time ago, but I seem to recall the DataTmp and ConversionMap are defined in the qvw attached to the original post. Open that qvw for more info.

If you want a better response, you might start a new thread on this topic. You can always put a link back to this thread in your post.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein