QlikView set analysis with date: nothing result - qlikview

I have a problem with a set analysis in QlikView with the date.
I have created a table that contains the sales order.
One field contains the dates of requesting products.
Now if I use a set analysis to filter the data, I receive 0.
The code used that is not working is below.
If I use a set analysis with one date (see below) I receive the orders that have that date in Ord.Original.Req.Date.
Any suggestion?
code not working:
sum({$< Ord.Campain={$(=(max(Ord.Campain)-1))},
Ord.Original.Req.Date = {"$(='<=' & Date(monthend($(vMaxDateAP)), 'DD/MM/YYYY')"}>}
Ord.T.Amm)
code working but with one date:
sum({$<[Ord.Original.Req.Date] ={'31/01/2018'}>}Ord.T.Amm)

try this
sum({$< Ord.Campain={"$(=max(Ord.Campain)-1)"}, Ord.Original.Req.Date = {"<=$(=Date(monthend($(vMaxDateAP)), 'DD/MM/YYYY'))"}>}Ord.T.Amm)

Related

QlikSense Expression Displaying only Previous Month's Values

I have started working with QS recently and I have a problem with defining an expression which will allow me to display previous month's data.
I have tried creating previous month variable:
vPreviousMonth = MonthName(Addmonths(Max([Calendar Termination Month]),-1))
however this did not work - retrieves value 0. Then I tried below:
If(MonthStart([Calendar Termination Month])=MonthStart(Today()),-1,0) as PreviousMonth which doesn't work either - retrieves current month's values, used in below expression:
sum({<PreviousMonth={"-1"}>} [Terminated]).
Lastly, I tried
sum({$<[Calendar Termination Month]={"$(=[Calendar Termination Month](AddMonths(Max(Date),-1),'YYYY-MM'))"}>}[Terminated])
which, surprise!, retrieved 0 value as well.
Is there any way I can somehow make this work?
Try this
sum({$<[Calendar Termination Month]={"$(=month(AddMonths([Termination Date],-1))))"}>}[Terminated])

BAPI/FM to search prod orders confirmations by workcenter and date?

I'm trying to figure out which BAPI/FM I could use to search amounts confirmed based on search criteria of date (+time if possible) and workcenter confirmed where was confirmed...
I would be using BAPI_PRODORDCONF_GETDETAIL which contains these informations, but according to BAPI guide I can only load in the data of confirmation number+confirmation counter.
Therefore the option would be to run BAPI_PRODORDCONF_GETLIST (but I can only input the production order range or confirmation number range), then filter what includes the workcenter and date I need and from those pick up confirmation number+counter and run it through BAPI_PRODORDCONF_GETDETAIL.
but this procedure of getting list of everything without data being filtered on serverside is extemly timeconsuming and out of SAP Gui I have timeout error... therefore I need any BAPI/FM which I could input the workcenter where was confirmed and date, and have the data filtered already...
Any ideas how to do that?
As far as I know there is no such standard FM, so your only choice is custom development.
I would suggest you MCPK transaction were this info is exposed in a handy form, but as I see that your requirement is to receive this info externally this is not appropriate for you.
The confirmations reside in AFRU table and workcenters are in CRHD, so to find confirmed quantities by workcenter you should join these tables, or use a view u_15673 where this info is linked:
TYPES: BEGIN OF prod_orders,
rueck TYPE afru-rueck, "confirmation number
rmzhl TYPE afru-rmzhl," confirmation counter
gmnga TYPE afru-gmnga, " quantity
arbid TYPE crhd-arbpl, " workcenter
END OF prod_orders.
DATA: orders TYPE TABLE OF prod_orders.
SELECT *
FROM u_15673
INTO CORRESPONDING FIELDS OF TABLE orders
WHERE isdd >= '20180101' AND isdz <= '163000'.
To pull this externally, you must create RFC-enabled FM or use RFC_READ_TABLE and fetch this view with parameters, here is the sample.
Another approach is to use RFC_ABAP_INSTALL_AND_RUN. You must create an ABAP program that uses WRITE for output the results as a standard list to screen.
Send the lines of this program to RFC_ABAP_INSTALL_AND_RUN to PROGRAM parameter and the code will be executed on the remote system and this FM will return screen results as the lines of table WRITES.
Possible sample based on MCPK tcode to send to RFC_ABAP_INSTALL_AND_RUN:
CLEAR lwa_selection.
lwa_selection-selname = 'SL_SPTAG'.
lwa_selection-sign = 'I'.
lwa_selection-option = 'BT'.
lwa_selection-low = '20180101'.
lwa_selection-high = '20201231'.
APPEND lwa_selection TO li_selection.
CLEAR lwa_selection.
lwa_selection-selname = 'SL_ARBPL'.
lwa_selection-sign = 'I'.
lwa_selection-option = 'EQ'.
lwa_selection-low = '10400001'.
APPEND lwa_selection TO li_selection.
SUBMIT rmcf0200 WITH SELECTION-TABLE li_selection
with par_stat = abap_true
EXPORTING LIST TO MEMORY
AND RETURN.
DATA: xlist TYPE TABLE OF abaplist.
DATA: xtext TYPE TABLE OF char200.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = xlist.
CALL FUNCTION 'LIST_TO_TXT'
EXPORTING
list_index = -1
TABLES
listtxt = xtext
listobject = xlist.
IF sy-subrc = 0.
LOOP AT xtext ASSIGNING FIELD-SYMBOL(<text>).
WRITE <xtext>.
ENDLOOP.
ENDIF.
However, this approach is not flexible because MCPK standard layout is a bit different than you want, and is not easy to adjust programmatically.
Because of that I recommend to stick to the RFC_READ_TABLE approach.

Filter parent data source with a field which is in another table in D365

Some times we need to filter a form grid based on the status of the transaction reference Id. Assume that we want to show purchase orders with confirm document state in arrival overview form. The document state field is located in the purch table. For this aim, I try to outer join WMSArrivalOverviewTmp to purch table and add Range. However the results is not as I expect.
This is the code I have tried in the initialized data source event:
[FormDataSourceEventHandler(formDataSourceStr(WMSArrivalOverview, WMSArrivalOverviewTmp), FormDataSourceEventType::Initialized)]
public static void WMSArrivalOverviewTmp_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
QueryBuildDataSource qbds = sender.queryBuildDataSource();
QueryBuildDataSource qbdsPO;
qbdsPO = qbds.addDataSource(tableNum(PurchTable));
qbdsPO.clearRange(fieldNum(PurchTable, DocumentState));
qbdsPO.joinMode(JoinMode::OuterJoin);
qbdsPO.fetchMode(QueryFetchMode::One2One);
qbdsPO.addLink(fieldNum(WMSArrivalOverviewTmp, InventTransRefId ),fieldNum(PurchTable, PurchId), qbds.name());
qbdsPO.relations(false);
qbdsPO.addRange(fieldNum(PurchTable, DocumentState)).value(SysQuery::value(VersioningDocumentState::Confirmed));
info(sender.query().toString());
}
This is the query which has been shown :
SELECT FIRSTFAST * FROM WMSArrivalOverviewTmp(WMSArrivalOverviewTmp)
OUTER JOIN FROM PurchTable(PurchTable_1) ON
WMSArrivalOverviewTmp.InventTransRefId = PurchTable.PurchId AND
((DocumentState = 40))
Also, I have changed the event type to query executing but I get errors:
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Error converting
data type nvarchar to bigint.
Cannot select a record in Purchase orders (PurchTable). The SQL
database has issued an error.
P.S. I have noticed that the error comes when I click on the update button after I fill one of the field in the filter section(arrival option). For example when I fill account number or warehouse. And also I have noticed that when I click on the update button while the fields are not filled in the filter section the join operation has not applied correctly, i.e., the purchase orders which have draft status are shown.
Your actual query looks correct to me. I would add that you may want to add the link between the WMSArrivalOverviewTmp.InventTransType == InventTransType::Purch (or set qbds.relations(true) so that you use the table's built in relation), but I doubt that is the root of your problem. Of course it wouldn't hurt to make sure your query works in the manner that you expect it to by converting the results of the info() call you have into SQL code and run it in SSMS to double check the result set.
Also, I'm curious why would you put the event on the datasource you are trying to manipulate? I would recommend investigating to see if it can occur on the OnModified event of the "status of the transaction reference Id". Although perhaps I am misunderstanding - if this situation is more of a "we need to happen all the time when the form loads" than a "some times we need" as you start your question off - the place to change the query is to modify it in a handler of the datasource's OnQueryExecuting event.
There are two ways of modifying the query on an event when an event occurs.
FormRun formRun = sender.formRun() as FormRun;
FormDataSource formDataSource = formRun.dataSource(formDataSourceStr(WMSArrivalOverview, WMSArrivalOverviewTmp));
//First way - get the base query and use executeQuery() to reload changes
Query query = formDataSource.query();
//modified query here.
formDataSource.executeQuery();
//Second way - get the current queryRun query and use research() to reload changes
Query query = formDataSource.queryRun.query();
//modified query here.
formDataSource.research();

How to read automatically-created variants

I need to read automatically-created variants, to get the selection screen parameters and other selection criteria. The names of such variants begin with symbol & (for example, &0000000000425). Such variants are created once you schedule any background job from se80/se38 or any transaction without choosing any existing variant (from the selection screen, menu Program -> Execute in background).
The function module RS_VARIANT_CONTENTS works fine for normal variants (which can be seen via se80/se38), but not for the automatically-created ones (that begin with &). I looked into the FM and found that the VARI table was read by the next code:
IMPORT %_VARI40C TO P_VARI
%_VARI40 TO L_VARI_40
%_VARI TO L_VARI
%_VARIVDAT TO P_VARIVDAT
* %_VARIDYN40 TO P_VARIDYN
%_VARIVDAT_DYN40 TO P_VDATDYN
DYNS_FIELDS TO OLD_DYNSFIELDS
DYNS_TEXPRI TO OLD_TEXPRI
DYNS_EXPR TO OLD_EXPR
DYNS_FIELD_TAB TO DYNS_FIELDS
DYNS_TEXPR TO DYN_SEL-TEXPR
FROM DATABASE VARI(VB) CLIENT L_CLIENT ID P_RKEY
ignoring structure boundaries
IGNORING CONVERSION ERRORS.
However the import returns nothing for the & variants. It looks like the values for & variants are stored within a format which is different from the format used by FM RS_VARIANT_CONTENTS.
Is there any way to find a proper format/data structure for & variants values?
Update: I created ZBC_TEST program and scheduled it as a job. I see a record in VARI table:
MANDT RELID REPORT VARIANT SRTF2
200 VB ZBC_TEST &0000000000425 0
So, the &0000000000425 variant exists in VARI table. VARI-CLUSTD field is not empty for the record. I use this code:
CALL FUNCTION 'RS_VARIANT_CONTENTS'
EXPORTING
REPORT = 'ZBC_TEST'
VARIANT = '&0000000000425'
MOVE_OR_WRITE = 'W'
IMPORTING
SP = lv_sp
TABLES
VALUTAB = lt_valtab.
The FM has been performed without any exception and sy-subrc=0, but lt_valtab table is empty...
The function module is working correctly: Since your program does not have any parameters, the returned value set is empty.

Podio API filtering by date range

I'm trying to filter tasks by date range and I'm getting errors whatever I try. This is how my request looks like: http://api.podio.com/task?completed=true&created_on%5Bfrom%5D=2016-06-23&created_on%5Bto%5D=2016-06-28&limit=100&offset=0&sort_by=rank&sort_desc=false&space=4671314
Here I'm trying to filter by created_on and I'm suplying {from: "2016-06-23", to: "2016-06-28"} but it's always returning the same error - invalid filter. I'm trying to filter tasks that are created in the last 5 days here.
The tasks API reference can be found in their API docs.
What am I doing wrong?
Date ranges can be separated by -.
To display "all my tasks created between 1st Jan 2014 and 1st Jan 2016" :-
/task?created_on=2014-01-01-2016-01-01&responsible=0'
Podio API get task filtering by date range use below :
/task/?created_on=2017-04-25-2017-05-01&offset=0&sort_by=rank&sort_desc=false&space=xxxxxxx