Is there BAPI equivalent to transaction CKMM? - abap

Is there a BAPI equivalent (or function module equivalent) to SAP transaction CKMM?
The goal is to change the price determination programmatically.
Everything I found is about updating price but not about updating price determination in material ledger.

No, there is no BAPI. I am wondering what the requirement here is.. CKMM should be a one time setting and it is already a mass change transaction.
Warning! If you change price control back and forth all previous recorded data in material ledger is lost!
So, I strongly advise to rethink your approach.

You can use LSMW script (Legacy System Migration Workbench) to run the transaction code CKMM (Change Price Determination) and fill in parameters and check results via programming.

Related

Event sourcing: Tracking each entity field changes in specific interval

I'm trying to figure out what could be the best solution for this use case:
there is a need to track each field changes in agreement entity. So when someone makes update for any field they must set when this is going to be applied (can set date in future or past). And later it should be possible to filter by some field's value in the past for specific date interval. So basically it's needed to have history of each field and apply correct value according to current date.
At first glance, it's possible to use event sourcing when entity is built from events on write side and for read side it could be used snapshots so on each new change for entity would be rebuild in SQL database table for quering operations.
Is there any simpler solution for this case?
Yes, ES could be an appropriate solution for your problem. You track all fields changes as separate events. And it would help if you create various read models according to your requirements.
If you need to store the history of each field change, you probably have a read model for this purpose and another for your last or per version snapshot of your read side entity.
Noice: You create your read models according to your current or future requirements. Maybe you need a new read model after 6 months, So you create another read model. BTW you can achieve this by using event sourcing.

Uploading Historical Work Orders via FM or BAPI

I am currently working on a project that requires me to upload historical work orders, notification, long texts, etc. After completing my initial development using BAPI "BAPI_ALM_ORDER_MAINTAIN", I noticed that this function module is creating regular work orders, not historical work orders.
Is there a way to designate in this BAPI that I would like historical orders to be created instead, or should I look at another function module?
EDIT: I have posted the answer below.
I know this is late, but I just remembered to update this. We ended up using a custom ABAP report paired with the SARA tool provided by SAP to update and archive orders

SAP BAPI for vendor creation and editing

Has anyone ever created a BAPI to create or edit a vendor in SAP R/3 4.6c in the background? I found two BAPIs: BAPI_VENDOR_CREATE and BAPI_VENDOR_EDIT, but both only work online (they call transactions XK01 and XK02).
Basically I need a way to call a function module that would do the same work as transactions XK01 and XK02 but don't need to be called online.
Looking on the SAP community forums, I found a lot of people with the same needs as me, but the answer was never complete.
Could someone give me a suggestion?
As you have discovered, SAP doesn't provide BAPIs for vendor creation/change that can be called in the background (this is, unfortunately, still the case in newer releases).
You have a few possible options:
Create your own BAPI, using (unreleased) SAP function modules for the vendor update.
Create your own BAPI, creating/changing the vendor via a BDC session.
I'd go with option 2. No, BDCs are never ideal and they have a lot of downsides but even a lot of SAP standard function modules for vendor creation seem to go that route and you'll at least be certain that the data in your system is consistent, unlike if you use something like function module VENDOR_INSERT, which does direct table updates without application validation.
Check if the standard vendor data transfer program (RFBIKR00) is in your system - it uses batch input so could be a very useful starting point for your BDC.

sql server global data version

I wonder what is the best way to implement global data version for database. I want for any modification that is done to the database to incerease the version in "global version table" by one. I need this so that when I talk to application users I know what version of data we are talking about.
Should I store this information in table?
Should I use triggers for this?
This version number can be stored in a configuration table or in a dedicated table (with one field).
This parameter should not be automatically updated because you are the owner of the schema and you are responsible for knowing when you need to update it. Basically, you need to update this number every time you deploy a new application package (regardless of the reason for the package: code or database change).
Each and every deployment package should take care of updating the schema version number and the database schema (if necessary)
I tend to have a globals or settings table with various pseudo-static values stored.
- Just one row
- Many fields
This can include version numbers.
In terms of maintaining the version number you refer to, would this change when the data content changes? If so, the a trigger would be useful. If you mean for the version number to relate to table structures, etc, I'd be more inclined to manage this by hand. (Some changes may be irrelevant as far as teh applications are concerned, or there maybe several changes wrapped up into a single version upgrade.)
The best way to implement a "global data version for database" is via your source control system and build process. When all the changes have been submitted and passed testing your build process will increment your versioning number schema.
The version number could be implemented in a stored procedure. The result of the call to the stored proc could be added to a screen in your app so you can avoid users directly accessing a table.
To complete the previous answers, I came across the concept of "Migrations" (from the Ruby on Rails world apparently) today, and there was already a question on SO that covered existing frameworks in .Net.
The concept is still to store DB versioning information as data in a table somewhere, but for that versioning information to be managed automatically by a framework, rather than manually by your custom deployment processes:
previous SO question with overview of options: https://stackoverflow.com/questions/313/net-migrations-engine

Is there any RFC or BAPI implementing the transaction rsscd001 for displaying change documents in SAP?

I would like to know whether there is any RFC or BAPI functions to display change documents (transaction RSSCD001) based on input query in SAP. The customer requirement is to implement a java monitor system on SAP without adding any ABAP functions on the SAP server.
I tried to make use of 'RFC_READ_TABLE' functions, which is deprecated according to the official documents, to read the CDPOS and CDHDR table and join them. But as vwegert said, to traverse the table CDPOS is really time-costing, as it contains billions of table entries.
My intention of this query is to find changes to all bank details of vendors.
Any other thoughts?
Many thanks in advance!
The least resource-consuming way to do this would be to use the workflow runtime system to actively notify the java application whenever a change document is written. You don't have to write any ABAP functions to do this, just setup the workflow engine (using the automatic customizing) and customize the event generation (documentation). Then, you write a java service that connects to the SAP system using JCo and registers as an RFC server using a destination of Type TCP/IP and a registered program ID. This java server program has to provide a function module handler that can be called using tRFC from the SAP system. Finally, add a linkage entry that will tell the workflow runtime system to call your java program each time a change document is written.
Of course, this will only record the changes that happen after installation, not the historical changes.
warning : I'm not very familliar with this field.
The RFC function BAPI_VENDOR_FIND (BAPI Vendor) seems to be used to find vendor based on values in table. You could use it to check gainst the modification date. This is not perfect, as there is no relationnal operator, only equals, and you'll have to check against several dates...
hopes this helps
Guillaume