SQL - Combining 3 rows per group in a logging scenario - sql

I have reworked our API's logging system to use Azure Table Storage from using SQL storage for cost and performance reasons. I am now migrating our legacy logs to the new system. I am building a SQL query per table that will map the old fields to the new ones, with the intention of exporting to CSV then importing into Azure.
So far, so good. However, one artifact of the previous system is that it logged 3 times per request - call begin, call response and call end - and the new one logs the call as just one log (again, for cost and performance reasons).
Some fields common are common to all three related logs, e.g. the Session which uniquely identifies the call.
Some fields I only want the first log's value, e.g. Date which may be a few seconds different in the second and third log.
Some fields are shared for the three different purposes, e.g. Parameters gives the Input Model for Call Begin, Output Model for Call Response, and HTTP response (e.g. OK) for Call End.
Some fields are unused for two of the purposes, e.g. ExecutionTime is -1 for Call Begin and Call Response, and a value in ms for Call End.
How can I "roll up" the sets of 3 rows into one row per set? I have tried using DISTINCT and GROUP BY, but the fact that some of the information collides is making it very difficult. I apologize that my SQL isn't really good enough to really explain what I'm asking for - so perhaps an example will make it clearer:
Example of what I have:
SQL:
SELECT * FROM [dbo].[Log]
Results:
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
| Session | Date | Level | Context | Message | ExecutionTime | Parameters | |
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call Begin | -1 | {"Input":"xx"} | |
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call Response | -1 | {"Output":"yy"} | |
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call End | 123 | OK | |
| F76BCBB | 2014-07-20 19:16:17 | ERROR | GET v1/def | Call Begin | -1 | {"Input":"ww"} | |
| F76BCBB | 2014-07-20 19:16:18 | ERROR | GET v1/def | Call Response | -1 | {"Output":"vv"} | |
| F76BCBB | 2014-07-20 19:16:18 | ERROR | GET v1/def | Call End | 456 | BadRequest | |
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
Example of what I want:
SQL:
[Need to write this query]
Results:
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
| Date | Level | Context | Message | ExecutionTime | InputModel | OutputModel | HttpResponse |
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
| 2014-07-20 19:16:15 | INFO | GET v1/abc | Api Call | 123 | {"Input":"xx"} | {"Output":"yy"} | OK |
| 2014-07-20 19:16:17 | ERROR | GET v1/def | Api Call | 456 | {"Input":"ww"} | {"Output":"vv"} | BadRequest |
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+

select L1.Session, L1.Date, L1.Level, L1.Context, 'Api Call' AS Message,
L3.ExecutionTime,
L1.Parameters as InputModel,
L2.Parameters as OutputModel,
L3.Parameters as HttpResponse
from Log L1
inner join Log L2 ON L1.Session = L2.Session
inner join Log L3 ON L1.Session = L3.Session
where L1.Message = 'Call Begin'
and L2.Message = 'Call Response'
and L3.Message = 'Call End'
This would work in your sample.

Related

Only show matching values from junction table

I have tables service and material and service_material.
The table service cointains warranty_dates that stores multiple values for all materials used on the service. The warranty length is in table material, and the warranty_dates in table service is calculated with service_date plus warranty lengths from table materials.
I'm trying to create a query in Access that will show me only the warranty dates for materials used on a service, so only the values that match the serviceid in service_material table.
Servis = Service, Datum = date, Garancija = warranty, Ime = name
SELECT DISTINCT Servis.Datum+Material.Garancija AS garancijski_rok, Servis.Datum, Material.Ime, Servis_Material.ServisID
FROM Servis
INNER JOIN (Material
INNER JOIN Servis_Material ON Material.MaterialID = Servis_Material.MaterialID) ON Servis.ServisID = Servis_Material.ServisID
WHERE (((Servis_Material.ServisID)=[Servis].[ServisID]) AND ((Servis_Material.materialid)=[material].[materialid]))
ORDER BY Servis_Material.ServisID;
This is what I have so far, but this query shows me all warranty dates for all materials used in services. I just want the query to show the matching materials that were used in service.
I'm a total beginner and I'm using Excel because it's a school project. Sorry cause it's in Slovenian. Hopefully it is still understandable.
This is the result atm. If it's possible I want it to only show materials for that particular service I am adding the warranty dates in.
Assuming you are working with access and not Excel and assuming the problem is mostly setting up the ManytoMany Relationship. Here is a Minimal Reproducible example starting with the Normalized Tables:
-------------------------------------------
| ServiceID | ServiceDate |
-------------------------------------------
| 1 | 12/12/2022 |
-------------------------------------------
| 2 | 12/5/2022 |
-------------------------------------------
----------------------------------------------------------------
| MaterialID | MaterialName | WarantyLength |
----------------------------------------------------------------
| 1 | PartA | 10 |
----------------------------------------------------------------
| 2 | PartB | 200 |
----------------------------------------------------------------
| 3 | PartC | 300 |
----------------------------------------------------------------
----------------------------------------------------------------
| MaterialServiceID | MaterialID | ServiceID |
----------------------------------------------------------------
| 1 | 1 | 1 |
----------------------------------------------------------------
| 2 | 2 | 1 |
----------------------------------------------------------------
| 3 | 3 | 1 |
----------------------------------------------------------------
| 4 | 1 | 2 |
----------------------------------------------------------------
| 5 | 2 | 2 |
----------------------------------------------------------------
Regarding Table Normalization, note how ServiceDate is the only thing hanging on Services and What would be more clearly named as MaterialWarantyLength is hanging on Materials. What would best be called LastDayofMaterialWaranty would be under MaterialsServices but we have a formula so we calculate that as needed.
One way of thinking about the next step is: Database users interact with the database through forms and reports. Among other things this protects the database from Users entering bad data and Protects the User from having to understand those normalized tables.
aside: the default forms are not good at protecting the database from bad data but they are a jump start.
So, the next step will be a query that puts the data for this relationship back together into one big table that the Database designer can understand. I find myself adjusting for the user when I design the User interface of forms and reports. Here I put everything into the designers query which is a good default as what you don't need for a particular form you just don't show.
'Warranty is a calculated Field.
'Note the use of DateAdd to handle all those calendar problems
'normally I extract the code for calculated fields into public functions for an example of that see here: https://stackoverflow.com/questions/74621501/ms-access-group-by-and-sum-if-all-values-are-available-query/74673498#74673498
Warranty: DateAdd("d",[Materials].[WarantyLength],[Services].[ServiceDate])
'here is the resulting sql for the designer query
'if you are following along try pasting the sql into the sql pane and then going to differnt tabs of the query designer
SELECT Services.ServiceID, Services.ServiceDate, MaterialsServices.MaterialID, Materials.WarantyLength, Materials.MaterialName
FROM Services INNER JOIN (Materials INNER JOIN MaterialsServices ON Materials.MaterialID = MaterialsServices.MaterialID) ON Services.ServiceID = MaterialsServices.ServiceID;
Running the query on the sample data gives:
-------------------------------------------------------------------------------------------------------------------
| ServiceID | ServiceDate | MaterialID | WarantyLength | MaterialName |
-------------------------------------------------------------------------------------------------------------------
| 1 | 12/12/2022 | 1 | 10 | PartA |
-------------------------------------------------------------------------------------------------------------------
| 1 | 12/12/2022 | 2 | 200 | PartB |
-------------------------------------------------------------------------------------------------------------------
| 1 | 12/12/2022 | 3 | 300 | PartC |
-------------------------------------------------------------------------------------------------------------------
| 2 | 12/5/2022 | 1 | 10 | PartA |
-------------------------------------------------------------------------------------------------------------------
| 2 | 12/5/2022 | 2 | 200 | PartB |
-------------------------------------------------------------------------------------------------------------------
At this point it is down to how you want the user to interact with the data. For instance, for a jump start I selected the query and used the create-form wizard to get a tabular style form and then added an unbound combobox to the header to allow the end user to filter the resulting form.
See here for an example: https://www.youtube.com/watch?v=uq3cgaHF6fc
The Final Form allows the end user to switch between viewing different services :
Private Sub cmbService_AfterUpdate()
Me.Filter = "ServiceID = " & Me.cmdService
Me.FilterOn = True
End Sub

Apply condition for a particular group: SQL

Currently I have to provide a report in BigQuery for Google Analytics of a format:
ClientID, SessionID, Source, Medium SessionNumber
So, the outcome has to be the table where for every ClientID, SessionNumber contains ordinal of an event occurred sorted by date
The problem is during one session a conversion occurs. So SessionNumber values for the particular ClientID do not end at the event where conversion occurs.
[For example, there are 30 events in a ClientID = 1, and conversion occurs at 15-th event (ordinal from SessionNumber)]
My question is how to delete all the data in a table after the ordinal in SessionNumber when conversion occurs?
So it would become possible to see when the lastclick occurred and and see the Assisted Conversion?
How to apply a condition for a particular group of data (for every client ID, in this case - REMEMBER that, here, for every ClientID we have a particular number of events and corresponding ordinals)
Example:
Client ID | SessionID | Source | Medium | SesionNumber | Goal Achieved (1 if yes)
1 | 456| google | cpc | 1 | 0
1 | 456| google | cpc | 2 | 0
1 | 456| google | cpc | 3 | 1
1 | 456| google | cpc | 4 | 0
2 | 234| ... ... ... ...
... ... ... ... ... ...
So, I have to get rid of all the rows after the SessionNumber when conversion occurred inside of each ClientID (Conversion occurs after the goal is achieved - I have already created such code). Is there any Syntax for standard SQL which would allow to create such condition for every ClientID ?
The thing is that inside one session conversion may occur and after that user can do other things as well, but I only need records from the start of the session until conversion occurs
I would like to return the table (from the example):
Client ID | SessionID | Source | Medium | SesionNumber | Goal Achieved (1 if yes)
1 | 456| google | cpc | 1 | 0
1 | 456| google | cpc | 2 | 0
1 | 456| google | cpc | 3 | 1
2 | 234| ... ... ... ...
... ... ... ... ... ...

SQL to set a value based on a value from a diffrent table automatically

The title may not be that helpful but what I am trying to do is this.
For simplicity's sake I have two tables one called logs and another called Log controls
In LOGS I have and a log event column, this is automatically populated by imported information. On the LOG CONTROLS I have a manually entered list of Log events (to match the ones coming in) and I have this table to have them assigned ID numbers and other details about the event.
What I need to do is have a column in the LOGS table which looks at the Log events, matches it to the ID from the LOG CONTROLS table and assigns the ID into the LOGS table.
I have seen a few methods of changing information in columns based of information in other tables but all of these seem to be one way checks i.e if ID = X change to VALUE FROM OTHER TABLE where as what I need is IF VALUE = X FROM OTHER TABLE CHANGE ID FIELD TO = Y FROM OTHER TABLE
Below is a mock up of the tables.
+----+-----------+----------+------------+
| ID | Date_Time | Event | Control ID|
+----+-----------+----------+------------+
| 1 | 0/0/0 | Shutdown | |
| 2 | 0/0/0 | Start up | |
| 3 | 0/0/0 | Error | |
| 4 | 0/0/0 | Info | |
| 5 | 0/0/0 | Shutdown | |
| 6 | 0/0/0 | Error | |
+----+-----------+----------+------------+
+-------------------+----------+--------+-------+
| Control ID | Event | Export | Flag |
+-------------------+----------+--------+-------+
| 1 | Shutdown | TRUE | TRUE |
| 2 | Start up | TRUE | FALSE |
| 3 | Error | TRUE | TRUE |
| 4 | Info | TRUE | FALSE |
+-------------------+----------+--------+-------+
So I need the Control ID in the first table to match the control ID from the second table depending on what the event was.
I hope this makes sense.
Any help or advice would be greatly appreciated.
From your description, it seems that a simple UPDATE statement is all you need:
update logs
set control_id = c.control_id
from log_controls as c
where c.event = logs.event;

Last accessed timestamp of a Netezza table?

Does anyone know of a query that gives me details on the last time a Netezza table was accessed for any of the operations (select, insert or update) ?
Depending on your setup you may want to try the following query:
select *
from _v_qryhist
where lower(qh_sql) like '%tablename %'
There are a collection of history views in Netezza that should provide the information you require.
Netezza does not track this information in the catalog, so you will typically have to mine that from the query history database, if one is configured.
Modern Netezza query history information is typically stored in a dedicated database. Depending on permissions, you may be able to see if history collection is enabled, and which database it is using with the following command. Apologies in advance for the screen-breaking wrap to come.
SYSTEM.ADMIN(ADMIN)=> show history configuration;
CONFIG_NAME | CONFIG_DBNAME | CONFIG_DBTYPE | CONFIG_TARGETTYPE | CONFIG_LEVEL | CONFIG_HOSTNAME | CONFIG_USER | CONFIG_PASSWORD | CONFIG_LOADINTERVAL | CONFIG_LOADMINTHRESHOLD | CONFIG_LOADMAXTHRESHOLD | CONFIG_DISKFULLTHRESHOLD | CONFIG_STORAGELIMIT | CONFIG_LOADRETRY | CONFIG_ENABLEHIST | CONFIG_ENABLESYSTEM | CONFIG_NEXT | CONFIG_CURRENT | CONFIG_VERSION | CONFIG_COLLECTFILTER | CONFIG_KEYSTORE_ID | CONFIG_KEY_ID | KEYSTORE_NAME | KEY_ALIAS | CONFIG_SCHEMANAME | CONFIG_NAME_DELIMITED | CONFIG_DBNAME_DELIMITED | CONFIG_USER_DELIMITED | CONFIG_SCHEMANAME_DELIMITED
-------------+---------------+---------------+-------------------+--------------+-----------------+-------------+---------------------------------------+---------------------+-------------------------+-------------------------+--------------------------+---------------------+------------------+-------------------+---------------------+-------------+----------------+----------------+----------------------+--------------------+---------------+---------------+-----------+-------------------+-----------------------+-------------------------+-----------------------+-----------------------------
ALL_HIST_V3 | NEWHISTDB | 1 | 1 | 20 | localhost | HISTUSER | aFkqABhjApzE$flT/vZ7hU0vAflmU2MmPNQ== | 5 | 4 | 20 | 0 | 250 | 1 | f | f | f | t | 3 | 1 | 0 | 0 | | | HISTUSER | f | f | f | f
(1 row)
Also make note of the CONFIG_VERSION, as it will come into play when crafting the following query example. In my case, I happen to be using the version 3 format of the query history database.
Assuming history collection is configured, and that you have access to the history database, you can get the information you're looking for from the tables and views in that database. These are documented here. The following is an example, which reports when the given table was the target of a successful insert, update, or delete by referencing the "usage" column. Here I use one of the history table helper functions to unpack that column.
SELECT FORMAT_TABLE_ACCESS(usage),
hq.submittime
FROM "$v_hist_queries" hq
INNER JOIN "$hist_table_access_3" hta
USING (NPSID, NPSINSTANCEID, OPID, SESSIONID)
WHERE hq.dbname = 'PROD'
AND hta.schemaname = 'ADMIN'
AND hta.tablename = 'TEST_1'
AND hq.SUBMITTIME > '01-01-2015'
AND hq.SUBMITTIME <= '08-06-2015'
AND
(
instr(FORMAT_TABLE_ACCESS(usage),'ins') > 0
OR instr(FORMAT_TABLE_ACCESS(usage),'upd') > 0
OR instr(FORMAT_TABLE_ACCESS(usage),'del') > 0
)
AND status=0;
FORMAT_TABLE_ACCESS | SUBMITTIME
---------------------+----------------------------
ins | 2015-06-16 18:32:25.728042
ins | 2015-06-16 17:46:14.337105
ins | 2015-06-16 17:47:14.430995
(3 rows)
You will need to change the digit at the end of the $v_hist_table_access_3 view to match your query history version.

"Update Terminated" on /nva01 transaction

While running the SAP-SD benchmarking process on 3 tier SAP setup, a number of transactions are fired by automated users.
The following steps are executed,
6 /nva01 (Create Sales Order)
[ENTER]
7 Order Type or
Sales Organization 0001
Distribution Channel 01
Division 01
[ENTER]
8 Sold-to party sdd00000
PO Number perf500
Req.deliv.date 22.12.2009
Deliver.Plant 0001
Material Order quantity
sd000000 1
sd000001 1
sd000002 1
sd000003 1
sd000004 1
[F11] (Save)
9 [F3] (Back)
(This dialogstep is needed only to get 4 dialogsteps for VA01 as defined
for the SD benchmarks)
whenever [F11] is pressed after entering information, it saves successfully. However, when [F3] is pressed, it shows error “unable to update”
Then I manually tried to execute the same steps
6 /nva01 (Create Sales Order)
[ENTER]
7 Order Type or
Sales Organization 0001
Distribution Channel 01
Division 01
[ENTER]
8 Sold-to party sdd00000
PO Number perf500
Req.deliv.date 22.12.2009
Deliver.Plant 0001
Material Order quantity
sd000000 1
sd000001 1
sd000002 1
sd000003 1
sd000004 1
On pressing [F11] it successfully saves. But when [F3] is pressed to go back to previous screen, it gives “update was terminated” error.
[F11] (Save)
9 [F3] (Back)
Then to locate the root cause of error, SM13 transaction and it shows the following details for the error
There is a large number of same errors in logs, and the update key for all the error entries is the same “4A08B4400C022793E10000000FD5F53D” is this normal..?
On googling found out that the possible reason for this error could be
Key already exists in table and duplicate entry is disallowed.
Which table is affected by this transaction..? how to resolve..?
Document number ranges issue
Which document number range to modify..? how to resolve..?
Kindly advise how to resolve this
edit including system log--
Runtime Errors SAPSQL_ARRAY_INSERT_DUPREC Exception
CX_SY_OPEN_SQL_DB Date and Time 12.05.2009 06:59:27
---------------------------------------------------------------------------------------------------- |Short text
| | The ABAP/4 Open SQL array insert results in duplicate database
records. |
---------------------------------------------------------------------------------------------------- |What happened?
| | Error in the ABAP Application Program
| |
| | The current ABAP program "SAPLV05I" had to be terminated
because it has | | come across a statement
that unfortunately cannot be executed.
|
---------------------------------------------------------------------------------------------------- |What can you do?
| | Note down which actions and inputs caused the error.
| |
| |
| | To process the problem further, contact you SAP system
| | administrator.
| |
| | Using Transaction ST22 for ABAP Dump Analysis, you can look
| | at and manage termination messages, and you can also
| | keep them for a long time.
|
---------------------------------------------------------------------------------------------------- |Error analysis
| | An exception occurred that is explained in detail below.
| | The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB',
was not caught | | in
| | procedure "SD_PARTNER_UPDATE" "(FUNCTION)", nor was it
propagated by a RAISING | | clause.
| | Since the caller of the procedure could not have anticipated
that the | | exception would occur, the
current program is terminated. | |
The reason for the exception is:
| | If you use an ABAP/4 Open SQL array insert to insert a record
in | | the database and that record
already exists with the same key, | |
this results in a termination.
| |
| | (With an ABAP/4 Open SQL single record insert in the same error
| | situation, processing does not terminate, but SY-SUBRC is set
to 4.) |
---------------------------------------------------------------------------------------------------- |How to correct the error
| | Use an ABAP/4 Open SQL array insert only if you are sure that
none of | | the records passed already
exists in the database. | |
| | If the error occures in a non-modified SAP program, you may be
able to | | find an interim solution in an
SAP Note. | |
If you have access to SAP Notes, carry out a search with the following
| | keywords:
| |
| | "SAPSQL_ARRAY_INSERT_DUPREC" "CX_SY_OPEN_SQL_DB"
| | "SAPLV05I" or "LV05IU15"
| | "SD_PARTNER_UPDATE"
| |
| | If you cannot solve the problem yourself and want to send an
error | | notification to SAP, include
the following information: | |
| | 1. The description of the current problem (short dump)
| |
| | To save the description, choose "System->List->Save->Local
File | | (Unconverted)".
| |
| | 2. Corresponding system log
| |
| | Display the system log by calling transaction SM21.
| | Restrict the time interval to 10 minutes before and five
minutes | | after the short dump. Then
choose "System->List->Save->Local File | |
(Unconverted)".
| |
| | 3. If the problem occurs in a problem of your own or a modified
SAP | | program: The source code of the
program | |
In the editor, choose "Utilities->More
| | Utilities->Upload/Download->Download".
| |
| | 4. Details about the conditions under which the error occurred
or which | | actions and input led to the
error. | |
| | The exception must either be prevented, caught within proedure
| | "SD_PARTNER_UPDATE" "(FUNCTION)", or its possible occurrence
must be declared | | in the
| | RAISING clause of the procedure.
| | To prevent the exception, note the following:
|
---------------------------------------------------------------------------------------------------- |System environment
| | SAP-Release 701
| |
| | Application server... "hpvm-202"
| | Network address...... "15.213.245.61"
| | Operating system..... "HP-UX"
| | Release.............. "B.11.31"
| | Hardware type........ "ia64"
| | Character length.... 16 Bits
| | Pointer length....... 64 Bits
| | Work process number.. 10
| | Shortdump setting.... "full"
| |
| | Database server... "ghoul3"
| | Database type..... "ORACLE"
| | Database name..... "E64"
| | Database user ID.. "SAPSR3"
| |
| | Terminal.......... "hpvmmsa"
| |
| | Char.set.... "C"
| |
| | SAP kernel....... 701
| | created (date)... "Feb 24 2009 21:53:01"
| | create on........ "HP-UX B.11.23 U ia64"
| | Database version. "OCI_102 (10.2.0.4.0) "
| |
| | Patch level. 32
| | Patch text.. " "
| |
| | Database............. "ORACLE 9.2.0.., ORACLE 10.1.0..,
ORACLE 10.2.0.." | | SAP database version. 701
| | Operating system..... "HP-UX B.11"
| |
| | Memory consumption
| | Roll.... 2013408
| | EM...... 0
| | Heap.... 0
| | Page.... 0
| | MM Used. 1966160
| | MM Free. 24336
|
---------------------------------------------------------------------------------------------------- |User and Transaction
| |
| | Client.............. 900
| | User................ "SAP_PERF000"
| | Language key........ "E"
| | Transaction......... "VA01 "
| | Transactions ID..... "4A08B9BC0C022793E10000000FD5F53D"
| |
| | Program............. "SAPLV05I"
| | Screen.............. "RSM13000 3000"
| | Screen line......... 2
|
---------------------------------------------------------------------------------------------------- |Information on where terminated
| | Termination occurred in the ABAP program "SAPLV05I" - in
"SD_PARTNER_UPDATE". | | The main program was
"RSM13000 ".
| |
| | In the source code you have the termination point in line 480
| | of the (Include) program "LV05IU15".
| | The program "SAPLV05I" was started in the update system.
| | The termination is caused because exception "CX_SY_OPEN_SQL_DB"
occurred in | | procedure "SD_PARTNER_UPDATE"
"(FUNCTION)", but it was neither handled locally | |
nor declared
| | in the RAISING clause of its signature.
| |
| | The procedure is in program "SAPLV05I "; its source code begins
in line | | 1 of the (Include program
"LV05IU15 ". |
---------------------------------------------------------------------------------------------------- |Source Code Extract
|
---------------------------------------------------------------------------------------------------- |Line |SourceCde
|
---------------------------------------------------------------------------------------------------- | 450| POSNR = I_XVBPA-POSNR
| | 451| PARVW =
I_XVBPA-PARVW. | | 452| IF
I_YVBPA-STCD1 <> I_XVBPA-STCD1 OR
| | 453| I_YVBPA-STCD2 <> I_XVBPA-STCD2 OR
| | 454| I_YVBPA-STCD3 <> I_XVBPA-STCD3 OR
| | 455| I_YVBPA-STCD4 <> I_XVBPA-STCD4 OR
| | 456| I_YVBPA-STCDT <> I_XVBPA-STCDT OR
| | 457| I_YVBPA-STKZN <> I_XVBPA-STKZN OR
| | 458| I_YVBPA-J_1KFREPRE <> I_XVBPA-J_1KFREPRE OR
| | 459| I_YVBPA-J_1KFTBUS <> I_XVBPA-J_1KFTBUS OR
| | 460| I_YVBPA-J_1KFTIND <> I_XVBPA-J_1KFTIND.
| | 461| MOVE-CORRESPONDING I_XVBPA TO WA_XVBPA3I.
| | 462| APPEND WA_XVBPA3I TO DA_XVBPA3I.
| | 463| ENDIF.
| | 464| ENDIF.
| | 465| ENDIF.
| | 466| WHEN UPDKZ_OLD.
| | 467| IF DA_VBPA-ADRDA CA GCF_ADDR_IND_COMB_MAN_OLD OR
| | 468| DA_VBPA-ADRDA CA GCF_ADDR_IND_COMB_MAN_ADRC.
| | 469| YADR-ADRNR = DA_VBPA-ADRNR. COLLECT YADR.
| | 470| ENDIF.
| | 471| IF DA_VBPA-ADRDA CA GCF_ADDR_IND_COMB_MAN_OLD OR
| | 472| DA_VBPA-ADRDA CA GCF_ADDR_IND_COMB_MAN_ADRC.
| | 473| XADR-ADRNR = DA_VBPA-ADRNR. COLLECT XADR.
| | 474| ENDIF.
| | 475| ENDCASE.
| | 476| ENDLOOP.
| | 477| UPDATE (OBJECT) FROM TABLE DA_XVBPAU.
| | 478| UPDATE VBPA3 FROM TABLE DA_XVBPA3U.
| | 479|
| |>>>>>| INSERT (OBJECT) FROM TABLE DA_XVBPAI.
| | 481| INSERT VBPA3 FROM TABLE DA_XVBPA3I.
| | 482|
| | 483| IF SY-SUBRC > 0.
| | 484| MESSAGE A700 WITH OBJECT SY-SUBRC DA_XVBPAI(21).
| | 485| ENDIF.
| | 486|
| | 487|* Sonderfall neue VBPA (VBPA2) für Rollen AA und AW
| | 488| LOOP AT I_XVBPA2.
| | 489| DA_VBPA2 = I_XVBPA2.
| | 490| CASE DA_VBPA2-UPDKZ.
| | 491| WHEN UPDKZ_NEW.
| | 492| IF DA_VBPA2-ADRDA CA GCF_ADDR_IND_COMB_MAN_OLD OR
| | 493| DA_VBPA2-ADRDA CA GCF_ADDR_IND_COMB_MAN_ADRC.
| | 494| XADR-ADRNR = DA_VBPA2-ADRNR. COLLECT XADR.
| | 495| ENDIF.
| | 496| I_XVBPA-MANDT = SY-MANDT.
| | 497| IF I_XVBPA2-VBELN IS INITIAL.
| | 498| I_XVBPA2-VBELN = F_VBELN.
| | 499| ENDIF.
|
It is very clear that system is trying to update with some duplicate record and hence, the update termination system is popping up. Take the help of ABAP team and check the root cause of this issue. Also if there is any customization involved in sale order creation process, then in that case also, this will happen. So you have to check with ABAP team. Alternatively, if you have login credentials for Service Marketplace, then have a look at OSS note 330904.