Update only non empty fields
Hi everybody,
I'm trying to develop a trigger-based solution for a project involving received messages from an MQ queue.
The messages are all inserted from the queue into a single staging table. (v10.2.0.4)
Each message's data will need to be either inserted or updated to a destination table based upon a field's value in the staging table.
I was planning on putting a trigger on the staging table and calling an insert or update procedure based on the staging field's value.
The inserts are pretty straightforward.
It's the updates that I'm struggling with - some of the staging fields will be populated, others will be empty. There is no pattern to which fields will or will not be populated.
I do not want to update the destination table with empty fields - I only want to update fields that contain data.
Is there an better way than several "if-then check for empty, then update" (one for each field)?
Maybe some sort of magical dynamic update?
Any help is greatly appreciated.
Thanks in advance!
Hi,
You can use the NVL function (or COALESCE), which returns the first of its arguments that is NOT NULL.
Instead of:
UPDATE dest
SET column_a = x
, column_b = y
WHERE id = z;say
UPDATE dest
SET column_a = NVL (x, column_a)
, column_b = NVL (y, column_b)
WHERE id = z;If x IS NOT NULL, then NVL (x, column_a) will return x.
If x IS NULL, then NVL (x, column_a) will return column_a
You could also automate this in a BEFORE UPDATE trigger:
:NEW.column_a := NVL (:NEW.column_a, :OLD.column_a);
:NEW.column_b := NVL (:NEW.column_a, :OLD.column_b);but if you do, you'll have to disable the trigger to correct mistakes that really should be NULL.
Similar Messages
-
Updating a DB table with only non-empty values of a work area
Hi everybody,
Is that possible in ABAP to update a table in the database with a work area, but only with non-empty values of this work area?
Example:
data: ls_custom type ZCUSTOMERS_0.
ls_custom-CUSTOMER = '20'.
ls_custom-LASTNAME = 'MyName'.
ls_custom-FIRSTNAME = ' '.
ls_custom-CURRENCY = ' '.
update ZCUSTOMERS_0 from ls_custom. *" I want that the update clause don't do the update with FIRSTNAME and CURRENCY fields because they have empty values*
If it's possible, how to do it?
Thanks & regards,
AbdelTotal Questions: 81 (66 unresolved)
Hi,
To my understanding you mean if the database table has values
customer 20
lastname somename
firstname firstname
currency INR
so now after this
data: ls_custom type ZCUSTOMERS_0.
ls_custom-CUSTOMER = '20'.
ls_custom-LASTNAME = 'MyName'.
ls_custom-FIRSTNAME = ' '.
ls_custom-CURRENCY = ' '.
update ZCUSTOMERS_0 from ls_custom.
you want the result as
customer 20
lastname Myname
firstname firstname
currency INR
Is it so? Then Normal update
data: ls_custom type ZCUSTOMERS_0.
ls_custom-CUSTOMER = '20'.
ls_custom-LASTNAME = 'MyName'.
update ZCUSTOMERS_0 from ls_custom.
would do that.
Thanks,
Sri. -
Mdx : Sum up the measure from start but need only non empty rows
Hi All
i have created a calculated measure where it suming up all its previous avaialable values based on Date dimension.
Everything is working but we are getting all rows from that datetimension . how can get only till current date,
SUM(NULL:[Date].[Hierarchy].currentmember,[Measures].[SIMID])
Surendra ThotaHi Surendra,
According to your description, you want to calculate the sum up the measure from start for those non empty rows, right?
In this case, please try the query below.
WITH MEMBER [Measures].[Sum from start]
AS
SUM ({NULL:[Date].[Calendar].CurrentMember},
[Measures].[Internet Sales Amount])
SELECT {[Measures].[Internet Sales Amount],[Measures].[Sum from start]} ON 0 ,
nonempty([Date].[Calendar].[Calendar Year].MEMBERS) ON 1
FROM [Adventure Works]
Result
Besides, here is a blog which describe various way to calculate running total, please see:
http://blog.sqltechie.com/2011/01/various-way-to-calculate-running-total.html
Regards,
Charlie Liao
If you have any feedback on our support, please click
here.
Charlie Liao
TechNet Community Support -
Update of non-database fields mapped to database fields
I have two columns start month and start year which
are non-database columns and which map to one database
field start date in the database.
I have a post-query trigger on the start month and
start year fields to derive the value from the
database field start date when the form is queried.
When I try to update the form, the update does not
work - if I remove the post-query trigger then the
update works but, the month and year non-database
fields do not get queried.
Any help will be greatly appreciated.
Thanks,
Suzannesince those 2 fields are not connected to the database field you need to code the update to the database.
Use the pre-insert trigger and set the value of the date item according to the values of the 2 fields. -
Box for view only/non-updateable fields
How can I create a box for a column in JHeadstart that is marked as non-updateable (Update Allowed = false)? I have tried some code in the Additional Properties but have not been able to find the mix. Using disable will put a box, but it dims both the lable and the value and is unacceptablely light.
Edited by: user589963 on Apr 22, 2013 12:49 PMI tried a different approach by setting the attribute in JHeadstart to Updateable = False and then put this code in the Additional Properties space in Expert Mode:
contentStyle="border:1px solid;padding:0 5px 0;"
That created the box and it was not dimmed like it was when the field was disabled in JHeadstart before. But for all attributes that do not have a value present the box is elevated up into the field above it. The box is not elevated if there is a value in it. Appears to be a bug with JHeadstart. Was just curious if there is other code that would work in the Additional Properties space that would effect how the CSS displays the box. -
Response only shows empty fields
Hi all, just having some problems try to view my responses. If I Open or Save a response, the fields in the form appear blank - I can only see them if I Preview the form. Anyone know what's wrong?
Thanks a lot!!Hi,
You can use the NVL function (or COALESCE), which returns the first of its arguments that is NOT NULL.
Instead of:
UPDATE dest
SET column_a = x
, column_b = y
WHERE id = z;say
UPDATE dest
SET column_a = NVL (x, column_a)
, column_b = NVL (y, column_b)
WHERE id = z;If x IS NOT NULL, then NVL (x, column_a) will return x.
If x IS NULL, then NVL (x, column_a) will return column_a
You could also automate this in a BEFORE UPDATE trigger:
:NEW.column_a := NVL (:NEW.column_a, :OLD.column_a);
:NEW.column_b := NVL (:NEW.column_a, :OLD.column_b);but if you do, you'll have to disable the trigger to correct mistakes that really should be NULL. -
Issue copying only Non-Empty element via XSLT Transformation
Below transformation is copying even empty tag :( ...... I want only those tag with value copied.
<xsl:template match="/">
<ns56:ValidateProductForReactivationResponse>
<xsl:if test="$ValidateProductForReactivationResponse.payload/ns56:ValidateProductForReactivationResponse/internetService:InternetService">
<internetService:InternetService>
<internetService:CustomerUserName>
<xsl:value-of select="$ValidateProductForReactivationResponse.payload/ns56:ValidateProductForReactivationResponse/internetService:InternetService/internetService:CustomerUserName"/>
</internetService:CustomerUserName>
<internetService:Login>
<xsl:value-of select="$ValidateProductForReactivationResponse.payload/ns56:ValidateProductForReactivationResponse/internetService:InternetService/internetService:Login"/>
</internetService:Login>
</xsl:if>
</ns56:ValidateProductForReactivationResponse>
</xsl:template>
Please Help.
Regards,
EnEnceladus wrote:
I want something ..some pattern to put in match.. so that is covers whole xslt.Unfortunately, there's no such a thing... Document is quite clear on that point...
+" When mapping an optional source node to an optional target node, it is important to surround the mapping with an xsl:if statement that tests for the existence of the source node. If this is not done and the source node does not exist in the input document, an empty node is created in the target document. "+
http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_xslt_mpr.htm#CFAHAHHA -
Hi ,
I have a read only table in a jspx page. In case there is some error or there are no rows to display , I dont want to display the table. Just a label with some text.
There is a emptyText which checks if there are "no rows yet" , but it displays all the table headers etc and then displays the text.
Is there a way I can put in a check to display table only if records are present.
Thanks.
AmitHi Amit,
I would suggest you to make use of switcher instead of setting the visible property as in your case you not only want to show/hide the table based on some condition but also you want to toggle between a table or an output text based on some condition.
When switcher is used, based on the condition it evaluates which component to render in the component hierarchy since you don't want to load(render) a component when you don't want to make it available to the user.
There is a good example on how to use switcher component in this blog
Hope it helps.
Thanks & Regards,
~Krithika -
Updating and Loading a Matrix Row with Mix of DB and Non DB fields
Hi
I'm using SAPB1 2005 SP1 PL14 with B1DE 1.3
I have a matrix on a form that was generated by the UDO Form Generator. The Matrix contains data associated from a Document Lines table.
The underlying table and (therefor the matrix as well) only had 1 user field (column)
I've added a set of additional (read only) columns to the matrix together with supporting non db user datasources for each column. I've bound the new columns to the user datasources.
The new columns are only informational and should display data associated with the actual db field (column) in the matrix.
I require assistance / advice with 2 requirements:
<i>Requirement 1.
When loading the matrix, I'd like the non DB columns to be populated with data associated with the actual DB field.</i>
<i>Requirement 2.
When Adding / Updating the actual DB field in the matrix, I'd like the Non DB columns to be populated with the assocaited data.</i>
I've managed to get requirement 2 working by using a matrix onValidate Event. (not sure if this is the best approach?)
Any idea how I can achieve requirement 1 ?
Cheers,
BenHi Trinidad,
Putting the additaional columns in the table will result in me storing redundant info in the specific table.
The values are already stored in other related tables and I'd just like to display them as additional info fields.
.Ben -
Update non-editable field Start date which is calculated from other context
I had created some custom date fields(model, bol entity) in component ICCMP_BTSHEAD. We are calculating Start date based on the new input value into receiving date in the other context node.
so, for this i get the value on controller class(_IMPL). and pass the same value in the GET method of Start date.
But, Problem is Start date is the non-editable field so SET method will not be trigger as expected. so the same i used the DO_PREPARE_OUTPUT method but it's called and update the value when we press the enter. IF directly we click on the "SAVE" button then it' trigger but value is not updating in the database.
Please, find the below piece of code for the same. can u please anybody help me that how can i achieve this requirement.
DATA: l_recieve_date TYPE crmt_date_timestamp_from,
lr_current TYPE REF TO cl_bsp_wd_mixed_node,
lr_col TYPE REF TO cl_bsp_wd_collection_wrapper.
DATA: lv_date TYPE d,
lv_time TYPE t,
lv_date_temp TYPE sydatum.
IF iv_first_time EQ abap_false. "avoid for first tile load
Read the value of btreceivedate-TIMESTAMP_FROM.
lr_col = me->ztyped_context->btreceivedate->get_collection_wrapper( ).
IF lr_col IS BOUND.
lr_current ?= lr_col->get_current( ).
IF lr_current IS BOUND.
lr_current->if_bol_bo_property_access~get_property_as_value( EXPORTING iv_attr_name = 'TIMESTAMP_FROM'
IMPORTING ev_result = l_recieve_date ).
ENDIF.
ENDIF.
IF l_recieve_date IS NOT INITIAL.
CONVERT TIME STAMP l_recieve_date TIME ZONE sy-zonlo
INTO DATE lv_date TIME lv_time.
Check day is working day - if not, correct to previous working day
IF lv_date IS NOT INITIAL.
lv_date_temp = lv_date.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
correct_option = '-'
date = lv_date
factory_calendar_id = 'GB'
IMPORTING
date = lv_date_temp
EXCEPTIONS
date_after_range = 1
date_before_range = 2.
IF sy-subrc IS INITIAL.
lv_date = lv_date_temp.
ENDIF.
ENDIF.
CONVERT DATE lv_date TIME lv_time
INTO TIME STAMP l_recieve_date TIME ZONE sy-zonlo.
ENDIF.
lr_col = me->ztyped_context->btstart->get_collection_wrapper( ).
IF lr_col IS BOUND.
lr_current ?= lr_col->get_current( ).
IF lr_current IS BOUND.
lr_current->if_bol_bo_property_access~set_property(
iv_attr_name = 'APPT_TYPE' "#EC NOTEXT
iv_value = 'ZSTWTIME0001' ).
lr_current->if_bol_bo_property_access~set_property(
iv_attr_name = 'TIMESTAMP_FROM' "#EC NOTEXT
iv_value = l_recieve_date ).
ENDIF.
ENDIF.
ENDIF.
could you please help me?Hi,
Thanks for your reply,
yes, i checked the same thing also. But DO_HANDLE_DATA is called before the SET method of receiving date and in that case we are getting the old value in DO_HANDLE _DATA and source and Target fields both are not updating.
I checked, if, i'll change the input field then set method of input field and then EH_ON_SAVE is called directly.
i think, if i'll do the same modification in the EH_ON_SAVE method as i did in the DO_PREPARE_OUTPUT then it can be updated but i don't want to change the EH_ON_SAVE at this moment.
is there any other way to update the START DATE(Display mode in the screen) which is calculate from the other context node field receiving date. -
How to make Mandatory field as Non-empty
Hi All
I need to make a mandatory field as NON EMPTY.
How can i do that.
Please help me on this.
Thanks
SathishWhat have you tried so far?
-
Updating non-persistent fields in an Entity Object
Hi,
I wanted to add a non-persistent field to an Entity Object to use as a temporary aggregate field for a detail entity. It appears that storing data in the field makes it look like the master entity has been updated even though the value cannot be saved in the data base. Is this the way it is supposed to work?
I was trying to avoid putting invisible controls in the UI or creating "global" variables.
Thanks,
PeterThis can be done with programmatic VOs: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvvo.htm#sm0341
Sample: http://blogs.oracle.com/smuenchadf/examples/#132
You can also opt to do this with a simple Java class and a data control based on it.
For example: http://blogs.oracle.com/shay/2009/07/java_class_data_control_and_ad.html -
D7360 won't print in "Black Only", unless color cartridges are also non-empty
I'm trying to print a document in grayscale mode using D7360 Photosmart printer.
In the printing setup dialog am explicitly checking the option to use "Black Print Cartridge Only".
The printer refuses to print, saying:
"The following ink cartridges are empty: Light Cyan. Replace these ink cartridges to resume printing."
"The printer does not have enough ink to ensure printer's health. The empty ink cartridges must be replaced to resume."
Does this mean that even though it is not using the color cartridges, all of them have to be non-empty when the printer is operating?
This question was solved.
View Solution.I think I solved the problem for my PC. I put in a new black cartridge but my color cartridge is empty. My printouts started looking awful and were trying to print in blue. I went to the printer area of the control panel and requested grey scale only. Suddenly my printouts look great, as they did before. I'm running Vista on a Compaq with an HP deskjet D1560 printer.
-
LSMW to update only one field in materials
Hello experts,
My requirement is to update only one field 'HRKFT-Origin Group as Subdivision of Cost Element' in material using LSMW. I tried with Standard Batch/Direct Input -> Object - 0020, Method - 0000. But it was not successful as it gave me warning - 'The material cannot be maintained since no maintainable data transferred' at the end.
Now I want to try this using BAPI method in LSMW. But it is showing me error - No target structures could be determined..
Please guide me.
Regards,
Aparna GaikwadHi
i tried the same and am able to do it using LSMW Batch i/p. Object - 0020, Method - 0000.
There in source fields define material, plant and origin grp. in structure relations map the below
BGR00 Batch Input Structure for Session Data <<<< MBEW1 Material COsting
Select Target Structure BGR00 .
BMM00 Material Master: Transaction Data for Batch Input <<<< MBEW1 Material COsting
Select Target Structure BMM00 .
BMMH1 Material Master: Transfer of Main Data <<<< MBEW1 Material COsting
Next in field mapping map those 3 fields: material, plant and origin grp.
while testing do one thing. first take the data and try the same using MM02 manually. if tht is working fine ( i mean if the material is having costing view and you are able to chnage the origin group). then test with the same material, plant and a different origin grp. It will work. -
Update only one select query field
hello
how i can update select query result field in original table.
update table1 set field_1 from(select field_1 from table 1,table2,table3,table4 where table1.field_1=table1.field_1 and table2.field_2=table3.field_2 and table4.field_3=table1.field_4)
like that.is it possible!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!can u please help me to rewrite query/
select query returns result like that from different tables
lets example field_1 field_2 field_3 field_4
TIGER 1 V A
TIGER 2 F B
TIGER 3 R C
I need to update 'TIGER' instead of 'LION' in original table.
THANKSMaybe something like
update table1
set beast = (select animal
from <table_list>
where <predicates>
where beast = 'LION'when your query returns a single row
or when multiple rows are returned
update (select t1.beast,t2.animal
from (select beast,
<join_columns_list>
from table1
where beast = 'LION'
) t1,
(select animal,
<join_columns_list>
from <table_list>
where <predicates>
) t2
where t1.<join_columns_list> = t2.<join_columns_list>
set beast = animalRegards
Etbin
Maybe you are looking for
-
Z report for BED, ECS VAT values
Hello Experts, Here I have an issue we have developed the zreport for fetching the BED, ECS and Basic amount values for the particular Purchase orders with invoice posting dates as intial parameters. The report is giving error for each line items...t
-
Initialization in function module
hi all, i have created one function module, one of the select option is declared as S_BELNR TYPE RSELOPTION. i will have in the select option as SIGN OPTION LOW HIGH WE want to declare SIGN and OPTION default in the code itself as s_belnr-s
-
Datasource 2LIS_02_HDR enhancement
Hi Expert, Iu2019m working on datasource 2LIS_02_HDR enhancement - add a field u201CNet payment termu201D ( EKKO-ZTERM). I understand I can add this field in 2 ways as specified below a. Adding this field to Communication Structure (MCEKKO, in th
-
Internet Clients & Mac Enrollment
Hello, I'm having some issues with Internet Clients and Mac Enrollment, the latter via both the Intranet and Internet. Going over all the certificate steps again, the only thing I didn't do is have two FQDN for the Web Cert since I'm using the same
-
Changed password - can't connect
Hi, Someone has been using my internet and cauing me to go over my usage!! So I logged into http://bthomehub.home and entered my password, went to settings and chose to change the password for my wifi. I choose WAP-2 and entered my password. I was th