Informatica Expression IIF - etl

I have this set of codes in my Informatica expression
IIF(V_TR = 'TT'
OR
V_TR = 'TV'
OR
V_TR = 'VC'
OR
V_TR = 'TI'
OR
V_TR = 'TL'
OR
V_TR = 'NC'
OR
V_TR = 'CE'
OR
V_TR = 'D1'
OR
V_TR = 'DM'
OR
V_TR = 'N1'
OR
V_TR = 'NA'
OR
V_TR= 'U1'
OR
V_TR = 'UA', 'Y', 'N')
I know what the code means but what exactly does it do in the expression? DOes it serve as a filter to filter out all these values?

Without more context of what the expression and business needs of the expression it will be impossible to give more than guesses.
The 2 main ideas I can think of are:
The Y or N value are used later in a filter transform
The Y or N value is the desired output value based upon the input ports given the expression.

If the input port gets any of the value in OR clause it will return 'Y' else 'N'.

Related

Is it possible to change ITAB during aRFC parallel processing using TABLES parameter?

I'm currently designing parallel processing (by using aRFC), for mass GI job.
The problem is - How can i get return of EACH job result?
I used TABLES parameter, which are declared in main report (gt_result), and when aRFC is done, each FM doing MODIFY itab inside the function.
The problem is - inside each job, I checked data is changed(inside the gt_result), but when job is finished, and return to main report program, ITAB wasn't changed!
Is it possible to change ITAB value, using aRFC parallel processing? or Is it other way to get result from each job?
Any help will be appreciated. Thanks!
Edit : Here is a code snippet
Main Report :
DATA: g_task(20) TYPE n VALUE '100', "Task name administration
g_progs TYPE i, "Number of task in progress
g_sprog TYPE i, "Number of task started
g_eprog TYPE i, "Number of task finished
pa_wpnum TYPE int4 VALUE 5,
jobs TYPE int4 VALUE 100. "Number of task to be proceeded
TYPES : BEGIN OF gs_target,
matnr TYPE matnr_d,
cnt TYPE i,
END OF gs_target.
DATA : gt_target TYPE STANDARD TABLE OF gs_target,
wa_target TYPE gs_target.
DATA : gt_6040_para TYPE STANDARD TABLE OF zspp6040_para,
wa_6040_para TYPE zspp6040_para.
DATA : lv_cnt_seqno TYPE i,
lv_flag TYPE c.
DATA : gt_para_test TYPE STANDARD TABLE OF zpara_test,
wa_para_test TYPE zpara_test.
DATA : gv_fs_name(10) TYPE c.
** Test Data Append **
wa_target-matnr = 'A'.
wa_target-cnt = 300.
APPEND wa_target TO gt_target.
wa_target-matnr = 'B'.
wa_target-cnt = 657.
APPEND wa_target TO gt_target.
wa_target-matnr = 'C'.
wa_target-cnt = 1231.
APPEND wa_target TO gt_target.
wa_target-matnr = 'D'.
wa_target-cnt = 831.
APPEND wa_target TO gt_target.
wa_target-matnr = 'E'.
wa_target-cnt = 918.
APPEND wa_target TO gt_target.
** Test Data Append END **
** Split target into 1:300 ratio - for later use?
LOOP AT gt_target INTO wa_target.
DO.
lv_cnt_seqno = 1.
wa_target-cnt = wa_target-cnt - 300.
wa_6040_para-matnr = wa_target-matnr.
wa_6040_para-seqno = lv_cnt_seqno.
APPEND wa_6040_para TO gt_6040_para.
IF wa_target-cnt > 0.
lv_cnt_seqno = lv_cnt_seqno + 1.
ELSEIF wa_target-cnt <= 0.
CLEAR lv_cnt_seqno.
lv_flag = 'X'.
ENDIF.
IF lv_flag = 'X'.
CLEAR : lv_flag.
EXIT.
ENDIF.
ENDDO.
CLEAR : wa_6040_para.
ENDLOOP.
CLEAR : lv_flag.
** End Spliting Part **
** Making 'Data' Part - In real use, it should be the 'item' part of looping BAPI,
** Which are used for making GI document, containing 300 items.
LOOP AT gt_target INTO wa_target.
lv_cnt_seqno = 1.
DO.
wa_para_test-seqno = lv_cnt_seqno.
wa_para_test-matnr = wa_target-matnr.
APPEND wa_para_test TO gt_para_test.
lv_cnt_seqno = lv_cnt_seqno + 1.
IF lv_cnt_seqno = wa_target-cnt.
wa_para_test-seqno = lv_cnt_seqno.
wa_para_test-matnr = wa_target-matnr.
APPEND wa_para_test TO gt_para_test.
lv_flag = 'X'.
ENDIF.
IF lv_flag = 'X'.
CLEAR : lv_flag.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
** End of 'Data Making' Part.
** aRFC part, sending job for 'Matnr', looping 300 items AND changing gt_6040_para, which are used for checking Success, or Error.
LOOP AT gt_target INTO wa_target.
WAIT UNTIL g_progs LE pa_wpnum.
ADD 1 TO g_progs.
CALL FUNCTION 'Z_PP_PARA_TEST'
STARTING NEW TASK g_task DESTINATION IN GROUP DEFAULT
PERFORMING return_z_pp_para_test ON END OF TASK
EXPORTING
lv_matnr = wa_target-matnr
TABLES
zpara_target = gt_para_test
ztpp6040_change = gt_6040_para.
ADD 1 TO g_task.
ADD 1 TO g_sprog.
ENDLOOP.
** End of aRFC part.
WAIT UNTIL g_sprog <= g_eprog.
LOOP AT gt_6040_para INTO wa_6040_para.
WRITE : wa_6040_para-matnr, wa_6040_para-seqno, wa_6040_para-msgtx, wa_6040_para-msgty.
ENDLOOP.
aRFC Function Part :
FUNCTION z_pp_para_test.
DATA : lv_cnt TYPE int4.
DATA : lv_concat_data(10) TYPE c.
DATA : lv_index TYPE int4.
LOOP AT zpara_target WHERE matnr = lv_matnr.
lv_cnt = lv_cnt + 1.
zpara_target-msgtx = sy-tabix.
MODIFY zpara_target.
IF lv_cnt = 300.
lv_index = lv_index + 1.
READ TABLE ZTPP6040_CHANGE WITH KEY matnr = zpara_target-matnr
seqno = lv_index.
IF sy-subrc = 0.
ZTPP6040_CHANGE-msgty = 'S'.
ZTPP6040_CHANGE-msgtx = lv_index.
MODIFY ZTPP6040_CHANGE index sy-index.
ENDIF.
lv_cnt = 0.
ENDIF.
ENDLOOP.
ENDFUNCTION.
Returning Part
FORM return_z_pp_para_test USING taskname.
RECEIVE RESULTS FROM FUNCTION 'Z_PP_PARA_TEST'.
SUBTRACT 1 FROM g_progs.
ADD 1 TO g_eprog.
ENDFORM.
ZSPP6040_PARA Structure
MATNR MATNR_D
SEQNO INT4
MSGTX BAPI_MTYPE
MSGTY BAPI_MSG
ZPARA_TEST Structure
MATNR MATNR_D
SEQNO INT4
MSGTX BAPI_MTYPE
The RECEIVE RESULTS FROM FUNCTION instruction requires that you state which parameters you would like to receive and where you would like to store the results. Unfortunately all the parameters are optional, and those you don't explicitly mention just get discarded. So calling it with no parameters (like you do here) is pointless but still legal.
You likely declared the table you pass to the aRFC call as a global variable (don't do that!) and then in your FORM return_z_pp_para_test you again access that global table which wasn't changed yet.
In order to receive the actual results of the function-call, do this:
DATA: lt_results_target TYPE STANDARD TABLE OF gs_target,
lt_results_6040 TYPE STANDARD TABLE OF zspp6040_para.
RECEIVE RESULTS FROM FUNCTION 'Z_PP_PARA_TEST'
TABLES
zpara_target = lt_results_target
ztpp6040_change = lt_results_6040.
Now the local tables lt_results_target and lt_results_6040 should contain a copy of the data after it was changed by that asynchronous function-call.

case statement in where clause to return results set include nulls

im doing a jasper report that filters by multiple parameters which are optional using a case statement in the where clause. if the parameter is not entered i want results set to satisfy the other parameters also include nulls.
I did a case statement in the where clause.Excluding my last condition i get the results i want. when the param is empty i want the other conditions to b satisfied in result including null records which are satisfied by the other condition in the where clause
SELECT
cert.ice_certificate_date_issued AS "START_DATE",
cert.ice_current_license_expiry AS "END_DATE",
--licence_type,
ib.name AS "SHOP",
cert.ice_license_fee AS "SUPERMARKETPRICE",
dist.name AS "DISTRICT",
,iba.ice_price)
,0) AS "ACTIVITY_PRICE",
(select nvl(sum(taxamt),0) from c_ordertax where c_order_id = cert.c_order_id) AS "TAXAMT"
FROM icp_certificate cert
LEFT JOIN c_order ord ON cert.c_order_id = ord.c_order_id
LEFT JOIN icp_business ib ON cert.ice_foreign_trx_entity_id =
ib.icp_business_id
LEFT JOIN c_bpartner cbp ON cert.c_bpartner_id = cbp.c_bpartner_id
LEFT JOIN c_bpartner_location cbpl ON cert.c_bpartner_id =
cbpl.c_bpartner_id
LEFT JOIN icp_district dist ON cbpl.ice_district_id =
dist.ice_district_id
LEFT JOIN c_location loc on ib.c_location_id = loc.c_location_id
LEFT JOIN icp_business_activity_link ibal ON ib.icp_business_id =
ibal.icp_business_id
LEFT JOIN icp_business_activity iba ON ibal.icp_business_activity_id =
iba.icp_business_activity_id
WHERE
cert.ad_client_id = 1000555 AND
cert.ad_org_id = 2010520 AND
cert.icp_certificate_status = '01' AND
cert.isactive = 'Y' AND
cert.ice_certificate_type = '0051' AND
cert.ice_currentcertificate = 'Y' AND
cert.icp_certificate_date_issued BETWEEN '01-JAN-19' AND '23-MAY-19' AND
ib.ICp_District_ID = CASE WHEN 0>0 THEN 46445665 else ib.ICp_District_ID
END
--i want the else part to include record where ib.ICp_District_ID is null
return result of everything that is within the other conditions including records with district id as a null
It looks to me like you can use
.
.
.
(ib.ICp_District_ID = CASE
WHEN 0>0 THEN 46445665
else ib.ICp_District_ID
END
OR
ib.ICp_District_ID IS NULL)
which can be simplified to
NVL(ib.ICp_District_ID, -99) = NVL(ib.ICp_District_ID, -99)
because the CASE expression will always return ib.ICp_District_ID. It can be further simplified by just leaving out the condition which checks ib.ICp_District_ID completely, because it will always be satisfied. (Assuming, of course, that you intend to leave the condition WHEN 0 > 0 in place in the CASE expression, which is always FALSE, so it will always fall through to the ELSE).
Best of luck.

How do i return all other results from a CASE statement

i want my UCO column to show either a number 1 or 2, anything else i want to return the actual figure this could be any number figure. However currently it is showing and NULL because of my case statement.
Any ideas how to show the true figure?
SELECT S.STOPP_REAL_DELIVERY AS "Delivery Date",
case when C.COLLECT_COLLECTED_QTY = '-1' THEN '1'
when C.COLLECT_COLLECTED_QTY = '-2' THEN '2' END AS UCO
FROM MBR_COLLECT C,
MBR_STOPP S,
MBR_JOURNEY J
WHERE C.MARKET_CODE = 'UK'
AND C.COLLECT_TYPE_CODE = 4
AND C.STOPP_ID = S.STOPP_ID
AND J.JOURNEY_ID = S.JOURNEY_ID
AND J.JOURNEY_PLANNED_START >= '14-AUG-17';
Add an ELSE clause to the CASE statement:
SELECT S.STOPP_REAL_DELIVERY AS "Delivery Date",
CASE
WHEN C.COLLECT_COLLECTED_QTY = '-1' THEN '1'
WHEN C.COLLECT_COLLECTED_QTY = '-2' THEN '2'
ELSE C.COLLECT_COLLECTED_QTY
END AS UCO
FROM MBR_COLLECT C
INNER JOIN MBR_STOPP S
ON ( C.STOPP_ID = S.STOPP_ID )
INNER JOIN MBR_JOURNEY J
ON ( J.JOURNEY_ID = S.JOURNEY_ID )
WHERE C.MARKET_CODE = 'UK'
AND C.COLLECT_TYPE_CODE = 4
AND J.JOURNEY_PLANNED_START >= DATE '2017-08-14';
Also:
Use the ANSI join syntax (rather than the legacy comma-join syntax) as it makes it much easier to see how the tables are joined and avoids errors from the old (+) syntax.
'14-AUG-17' is not a date literal - it is a string literal. Oracle will try to implicitly convert it to a date literal if you are comparing it to a date column but this will be done using the NLS_DATE_FORMAT session variable as the format mask; this value is set per-user session and each user can change their own settings. If you rely on a default setting and the user changes it then your query will break (without having changed the query) for that user (and no others) and it will be very difficult to debug. Use an ANSI date literal instead DATE '2017-08-14' or explicitly state the format mask (and if you are using language specific month names then the language as well) TO_DATE( '14-AUG-17', 'DD-MON-RR','NLS_LANGUAGE="ENGLISH"' ).

How to select a name that contains the second letter is ā€œsā€ using LINQ?

enter image description here
How select a name from DATABASE that contains the second letter is "s" using LINQ ?
using lambda expressions:
var str = new string[] { "tsr", "mrg", "d" };
var result = str.Where(s => s.Length>1 && s[1] == 's');
The result variable will contain "tsr" value, and you are checking that the word have at least 2 characters otherwise an Exception would be thrown
from string str in myStrings
where str[1] == 's'
select str

How to select mondays with sqlite/sequel?

In my SQLite-DB I want to select all entries on a monday.
How can I do it with Sequel?
A test example:
require 'sequel'
DB = Sequel.sqlite()#'test.db')
DB.create_table(:days) do
String :text
Date :start
end
Date.today.upto(Date.today + 30){|d|
DB[:days].insert( :text => d.strftime("%Y-%m-%d day %w in week %W"), :start => d)
}
How can I select all mondays?
In native SQL I can do:
select * from days where strftime("%w", start) = "1"
Using this, I can define a view and select for it:
DB.run('create view mondays as select * from days where strftime("%w", start) = "1"')
p DB[:mondays].all
But I would like to use it from Sequel.
I tried
sel = DB[:days].filter{ start.strftime("%w", :start) == '1' }
#NoMethodError
sel = DB[:days].filter{ Sequel::SQL::Function.new(:strftime, "%w", :start) == '1' }
#SELECT * FROM `days` WHERE (1 = 0)
but without success.
Are there any other solutions?
I'm looking also for a possibility to select items by hour of day (all items with a timestamp, and then from 12:00-13:00 ...) I think this is the same problem and a solution for the day of week-selection will also solve my other problem.
Here are the problems with your examples:
sel = DB[:days].filter{ start.strftime("%w", :start) == '1' }
#NoMethodError
This uses a virtual row, so calling start returns a Sequel::SQL::Identifier. The Sequel::SQL::Identifier#strftime method does not exist, hence the NoMethodError.
sel = DB[:days].filter{ Sequel::SQL::Function.new(:strftime, "%w", :start) == '1' }
#SELECT * FROM `days` WHERE (1 = 0)
This fails because you are using ==. Sequel doesn't override ==, and ruby's default == returns false. On SQLite, Sequel represents false as (1 = 0).
This should work:
sel = DB[:days].filter{{strftime("%w", :start) => '1'}}
# SELECT * FROM `days` WHERE (strftime('%w', `start`) = '1')
This uses a hash (the inner {}) inside a virtual row block (the outer {}). In Sequel, equality is represented by hashes.

Resources