I have this data type to hold the information to create a notification.
DATA: LS_NOTIFHEADER LIKE BAPI2080_NOTHDRI.
I want to create a notification with a functional location and an affected functional location. I know I can add the functional location with
LS_NOTIFHEADER-TPLNR = '1010-XXXXXXXXXXXXXX'.
Is there also a field to add the affected functional location (BTPLN)?
This is the code I use to create the notification.
CALL FUNCTION 'BAPI_ALM_NOTIF_CREATE'
EXPORTING
NOTIF_TYPE = 'M1'
NOTIFHEADER = LS_NOTIFHEADER
IMPORTING
NOTIFHEADER_EXPORT = LS_NOTIF
TABLES
RETURN = LT_RETURN.
There is no possibility to specify affected location in BAPI.
But user-exit EXIT_SAPLIQS0_017 (enhancement QQMA0025) may be helpful for you. It is called by BAPI and there you can modify BTPLN.
Related
Is it possible to determine via code if the current system is R/3 or S/4?
I need it because I have a method that returns the software component of Human Resources related data, but this component should be different to R/3 and S/4 systems.
DATA(lv_software_component) = mo_configuration->get_software_component( ).
SELECT * FROM tadir INTO TABLE #DATA(lt_inftype_tables)
WHERE pgmid = 'R3TR'
AND object = 'TABL'
AND devclass IN ( SELECT devclass FROM tdevc
WHERE dlvunit = #lv_software_component
OR dlvunit = 'SAP_HRGXX'
OR dlvunit = 'SAP_HRRXX' )
On R/3, lv_software_component should be 'SAP_HRCMX', for example, while on S/4 it should be 'S4HCMCMX'. Currently, I have no idea on how to tell the difference between the releases, programmatically speaking.
The best I've come up with is hardcoding SY-SYSID, since I know which systems are S/4 and which aren't, but that shouldn't be ideal.
I appreciate any help, thanks!
You can use below class method for determining it. On the other hand is_s4h method only exists on S4 system. You need to check method exits before calling it.
cl_cos_utilities=>is_s4h( )
Working full example:
REPORT ZMKY_ISS4.
CLASS cl_oo_include_naming DEFINITION LOAD.
DATA oref TYPE REF TO if_oo_class_incl_naming.
DATA: lt_methods TYPE seop_methods_w_include,
lv_clskey TYPE seoclskey,
ls_cpdkey TYPE seocpdkey,
lv_iss4 TYPE abap_bool,
lt_params TYPE abap_parmbind_tab.
lv_clskey = 'CL_COS_UTILITIES'.
oref ?= cl_oo_include_naming=>get_instance_by_cifkey( lv_clskey ).
lt_methods = oref->get_all_method_includes( ).
ls_cpdkey-clsname = lv_clskey.
ls_cpdkey-cpdname = 'IS_S4H'.
READ TABLE lt_methods WITH KEY cpdkey = ls_cpdkey TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
lt_params = VALUE #( ( name = 'RV_IS_S4H'
kind = cl_abap_objectdescr=>returning
value = REF #( lv_iss4 ) ) ).
CALL METHOD CL_COS_UTILITIES=>('IS_S4H')
PARAMETER-TABLE
lt_params.
ELSE.
lv_iss4 = abap_false.
ENDIF.
Using the method cl_cos_utilities=>is_s4h is a rather unclean solution, because that method does not exist on older releases.
A cleaner method is to use the function module SFW_IS_BFUNC_SWITCHED_ON. This function module checks if a business function in the switch framework is enabled.
To check for the S4HANA on premise business function:
CALL FUNCTION 'SFW_IS_BFUNC_SWITCHED_ON'
EXPORTING
bfunc_name = 'SIMPLIFY_ON_PREMISE'
IMPORTING
is_switched_on = is_s4.
To check for the S4HANA on cloud business function:
CALL FUNCTION 'SFW_IS_BFUNC_SWITCHED_ON'
EXPORTING
bfunc_name = 'SIMPLIFY_PUBLIC_CLOUD'
IMPORTING
is_switched_on = is_s4.
By the way: The method cl_cos_utilities=>is_s4h actually uses this function module internally.
You might also want to check if it might be more appropriate in your use-case to use that function module to actually detect which HR business functions are active instead of deriving that information indirectly from whether or not the system has S/4 activated.
There's the function module OCS_GET_INSTALLED_COMPS which returns all software components installed. Note that it's not released by SAP. It used to work in old systems and still works in S/4HANA.
You can use function module DELIVERY_CHCK_ACTIVE_COMPONENT to check which of the two components is active.
I am also pretty sure only S/4 systems will have the S4CORE component active if you really need to check if it's S/4 or R/3.
When creating a new log object I want the subobject to be created on the fly if it doesn't exist yet.
This is what I have right now:
ls_log-object = mc_log_object.
ls_log-subobject = mv_log_subobject.
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = ls_log
IMPORTING
e_log_handle = mv_log_handle.
In order to avoid an error I check the object and subobject like this before:
CALL FUNCTION 'BAL_OBJECT_SUBOBJECT_CHECK'
EXPORTING
i_object = mc_log_object
i_subobject = mv_log_subobject
EXCEPTIONS
object_not_found = 1
subobject_not_found = 2
subobject_necessary = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 2.
mv_log_subobject = ''.
ENDCASE.
But I don't want to do it like this, I want to create a new subobject if it doesn't exist yet!
Is there some secret function call that can do this? :D
There is no secret function call or something similar. In fact SLG0 is nothing else than view cluster maintenance call (SM34). But I'm also wondering why you need this? If you need some more or dynamic differentiation of your logs you can you use field "extnumber" which you can set in your structure ls_log.
You can select in SLG1 with this field and also via log api.
I have got a function module that counts some variables in sap system and export it as single INT4. But when I try to use this in gateway service, it says me
"no output table mapped" How can i overcome it, I tried to put this variable in a table and export then but I couldnt.
DATA: EV_ENQ TYPE STANDARD TABLE OF seqg3.
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
guname = '*'
IMPORTING
number = EV_TABLESIZE
TABLES
enq = EV_ENQ.
Ev_Tablesize is the variable that I want to export. It holds the total lock count.
Your parameter should be mapped under your service implementation in SEGW. If it is not, then you should map them again and be sure that the parameter is being displayed.
I have problems to read the error codes and corresponding messages of SCI message classes.
Is there an way to easy access those?
I'm using "Praxishandbuch SAP Code Inspector" as a reference, but in that regard it is of no help.
I looked in Se11 but the information to the messages isn't helpful.
Has someone an approch to build such a table?
You can try this, perhaps it will work for you. I use the code below to get the access to all the errors found by Code Inspector for particular user(s):
data: ref_inspec_a type ref to cl_ci_inspection.
ref_inspec_a = cl_ci_inspection=>get_ref(
p_user = pa_iuser
p_name = pa_inam
p_vers = pa_ivers ).
data: ls_resp type scir_resp,
lt_resp type scit_resp.
clear: ls_resp, lt_resp.
ls_resp-sign = 'I'.
ls_resp-option = 'EQ'.
ls_resp-low = pa_fuser.
insert ls_resp into table lt_resp.
call method ref_inspec_a->get_results
exporting
p_responsibl = lt_resp
exceptions
insp_not_yet_executed = 1
overflow = 2
others = 3.
Playing around with LT_RESP you can get results for more users at the same time.
After you execute the code above, you can check the attributes SCIRESTPS and SCIRESTHD of the object REF_INSPEC_A. These are the large tables, which contain the result data of the SCI check. You can either work with them on your own, or you can simply pass the object REF_INSPEC_A into the function module SCI_SHOW_RESULTS to get regular SCI user interface.
I found out that you can get all the changeable messages (found in SCI GoTo/Management Of/ Message Priorities) can be read from the scimessages attribute of the test classes.
With this help you can get about 60% of all errors.
I'm trying to replace some un-reliable sap scripting we have in place to do an MB01 from a custom goods receipt application. I have come across the .NET connector and it looks like it could do a job for me.
Research has churned up the BAPI called BAPI_GOODSMVT_CREATE but can anyone tell me what parameters might be required to perform this transaction?
I have access to a SAP test environment.
BAPI_GOODSMVT_CREATE accepts a table of values called GOODSMVT_ITEM which contains 121 fields. I'm sure that not all of these fields are required.
Ultimately I guess my question is, what how can I work out which ones are required?
Do you have access to a SAP system? I have recently used this BAPI, and it has quite detailed documentation. To view the documentation, use transaction SE37, and enter the BAPI name. Unfortunately I don't currently have access to a system.
You will have to ask one of your MM/Logistics people to tell you what the movement type (BWART) is, and depending on the config you will need details like material number (MATNR), plant (WERKS), storage location etc.
MB01 is a Post GR for PO transaction, it is an equivalent of GM_Code 01 in MIGO or BAPI_GOODSMVT_CREATE. MIGO transaction is a modern successor for obsolete MB01.
So, as per the BAPI_GOODSMVT_CREATE documentation for GM_Code 01 the following fields are mandatory:
Purchase order
Purchase order item
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry or
quantity proposal
Here is the sample:
gmhead-pstng_date = sy-datum.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
gmcode-gm_code = '01'.
loop at pcitab.
itab-move_type = pcitab-mvt_type.
itab-mvt_ind = 'B'.
itab-plant = pcitab-plant.
itab-material = pcitab-material.
itab-entry_qnt = pcitab-qty.
itab-move_stloc = pcitab-recv_loc.
itab-stge_loc = pcitab-issue_loc.
itab-po_number = pcitab-pur_doc.
itab-po_item = pcitab-po_item.
concatenate pcitab-del_no pcitab-del_item into itab-item_text.
itab-move_reas = pcitab-scrap_reason.
append itab.
endloop.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gmhead
goodsmvt_code = gmcode
IMPORTING
goodsmvt_headret = mthead
tables
goodsmvt_item = itab
return = errmsg