PeopleCode reflection for variables - peoplesoft

Does PeopleCode have something similar to reflection in C# whereby I can access a variable with the variable name stored in a string? I am aware of the # operator but I think it only applies to fields and records (correct me if I am wrong. I tried and couldn't get it to work.)
Basically, I need to access a Component variable by name with the name itself being variable.

You can do it by # :
Local string &sValue1 = "var1";
getting the value :
winmessage(#(&sValue1));

Related

How to Pass Parameter Values at Runtime in Informatica Mapping Parameter

I have a scenario like we need to load data from source file to target table from a particular date [like LOAD_DATE], So I’ll create a mapping parameter for LOAD_DATE and pass that in Source Qualifier query. My query looks like this.
SELECT * FROM my_TABLE where DATE >= ‘$$LOAD_DATE’
So here I need to pass parameter values for ‘$$LOAD_DATE’ from another external database. I know that I need to pass the values from the Parameter file.
But my requirement is not to hardcore the values in the Parameter file but to feed it in runtime from another database. I will appreciate your help and thoughts on this.
You dont have to hardcode.
You can do it like this -
option 1. Create a mapping to create the param file in particular format.
Read for the other DB.
In expression transformation create below port which will generate actual param string. Pls note, we need to add new line so its recognized like a actual param file.
out_str = '[<<name of folder . name of workflow or sessoin>>]' || chr(12) ||
'$$LOAD_DATE='|||| CHR(39) ||<<date value from another DB>>|| CHR(39)
Then link above port to a flat file target. Name the output file as session_param.txt or whatever suitable. Pls make sure the parameter is generated correctly.
Use above file as a parameter file in your actual workflow.
Option 2 - You can join another table with original table flow. This can be difficult and need to change existing mapping.
Join the another table from another DB with main table based on a dummy condition. make sure you get distinct values of LOAD_DATE from another table. Make sure you always have 1 value from this DB.
Once you have the LOAD_DATE field from another table, you can use it in filter transformation to filter the data.
After this point you can add your original mapping.
Whole mapping should be like this-
SQ_MAIN_TABLE ----------------------->|
sq_ANOTHER_TABLE --DISTINCT_LOAD_DT-->JNR--FIL on LOAD_DT --><<your mapping logic>>

Data structure for key-value list in RFC-enabled function module?

I am writing a new RFC callable function in ABAP which should be able to import a list of key-values mapping.
The RFC calling application will use Python with the PyRFC library.
I am unsure whether I should create a new custom data structure of if I can re-use an existing data structure.
The import argument should be able to contain a list of this:
('key1', ['key1val1', 'key1val2', ...])
('key2', ['key2val1', 'key2val2', ...])
....
If possible I would like to re-use an existing data structure.
One ugly hack would be to design the API like this: use a string and parse at as json. But this is a work-around which I would like to avoid.
I found the data structure WDY_KEY_VALUE but there the value is a string. I would need a structure where the value is a list of strings.
You can create a deep structure with KEY defined with type STRING and VALUE defined with type STRINGTAB.
modelling such data is perfectly possible in ABAP DDIC:
create table type z_t_values with row being built in type string
create structure type z_s_key_values with fields key type string and values type z_t_values
create table type z_t_key_values with row type z_s_key_values
now, the type z_t_key_values corresponds to your example input: it is a table of rows, each row contains a single key and a table of values

procedure declaration error (PLS-00488)

I am trying to make a procedure return a subset of records as a single type a_ntt meeting a certain requirement for which I am trying to define a cursor a_cur, and this is the relevant code for my question:
a_t a_cur%ROWTYPE;
TYPE a_ntt IS TABLE OF a_t;
l_a a_ntt;
My database server throws PLS-00488 (invalid variable declaration object must be a type or subtype) considering variable a_t. I would like to know why. To me it seems I have provided a type to a_t, I would suggest ROWTYPE does that for me, but obviously I am not getting something.
I would like to know why this error occurs, why declaring a_t as a_cur%ROWTYPE does not prevent this.
Just to make sure, I have resolved the issue by adding %TYPE to the line, so TYPE a_ntt IS TABLE OF a_t%TYPE;, but I would like to know why this is necessary.
a_t is not a type. It is a variable whose type is a_cur%ROWTYPE. You can't use it as a type.
a_t%TYPE is a type though, so that works.
The syntax diagrams for the "collection variable declaration" is in the PL/SQL docs. You'll see that either you need a type, or a rowtype_attribute which has cursor, table or view name with %ROWTYPE attached, or a type_attribute which is essentially a variable name with %TYPE attached.

ASP.Net VB Check if datas exist in database

How do I check if data existing in the database or is NULL. I'm getting the following error Object cannot be cast from DBNull to other types . Do I need to add IsDBNULL to the code?
SignedOn.Text = Convert.ToDateTime(reader("SignedOn")).ToShortDateString()
you can check like below
If NOT IsDbNull(reader("SignedOn")) Then
SignedOn.Text = Convert.ToDateTime(reader("SignedOn")).ToShortDateString()
End If
Edit based on comments:
When you know the exact type of the column you can call method relevant to that type like reader.GetDateTime, reader.GetString etc
After conversion if there is a possibility of result can be null then you better check for null before calling ToShortDateString
You can use DateTime.TryParse method if you have store date time in varchar column

Binding Values To Prepared Statements without knowing their data type

I have a sqlite3 prepared statement. I know the number of values to bind to this prepared statement, but don't know their data types. (I just get a CSV file with the right values). Is there a generic bind method I can use for this? All the bind method in the documentation are for a specific data type.
I know that sqlite3 uses a dynamic type system. But it doesn't help if you are using the C API due to the absence of a generic bind method.
Any ideas/tricks anyone has tried?
The C API does not have a generic bind method because the C language does not have a generic type. Simply use the bind method for the type that you have, if it is wrong then sqlite will convert it for you.

Resources