ITXEX field cleared when HR_INFOTYPE_OPERATION is called - abap

We got into difficulties in maintaining the ITXEX field (Long text indication) of an Infotype record.
Say we got an existing record in an Infotype database table with a long text filled (ITXEX field value in that record is set to 'X').
Some process updates the record through HR_CONTROL_INFTY_OPERATION like this:
CALL FUNCTION 'HR_CONTROL_INFTY_OPERATION'
EXPORTING
infty = '0081'
number = '12345678'
subtype = '01'
validityend = '31.12.9999'
validitybegin = '19.05.2019'
record = ls_0081 " ( ITXEX = 'X' )
operation = 'MOD'
tclas = 'A'
nocommit = abap_true
IMPORTING
return = ls_return.
This call does update the record but clearing it's ITXEX field.
It's important to say that making the same action through PA30 does update the record and maintain ITXEX field as it was.
The described problem seems similar to that question. Trying the solutions given there didn't solve the problem.
Why the two approaches (PA30 and function module) don't work the same? How to fix this?

First of all, FM parameters you use are incorrect. How do you want the infotype to be updated if you set nocommit = TRUE?
Also, you are missing the correct sequence which must be used for the update procedure:
Lock the Employee
Read the infotype
Update the infotype
Unlock the Employee
The correct snippet for your task would be
DATA: ls_return TYPE bapireturn1.
DATA: l_infty_tab TYPE TABLE OF p0002.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = '00000302'
infty = '0002'
TABLES
infty_tab = l_infty_tab.
READ TABLE l_infty_tab ASSIGNING FIELD-SYMBOL(<infotype>) INDEX 1.
<infotype>-midnm = 'Shicklgruber'. " updating the field of infotype
CALL FUNCTION 'ENQUEUE_EPPRELE'
EXPORTING
pernr = '00000302'
infty = '0002'.
CALL FUNCTION 'HR_CONTROL_INFTY_OPERATION'
EXPORTING
infty = <infotype>-infty
number = <infotype>-pernr
subtype = <infotype>-subty
validityend = <infotype>-endda
validitybegin = <infotype>-begda
record = <infotype>
operation = 'MOD'
tclas = 'A'
IMPORTING
return = ls_return.
CALL FUNCTION 'DEQUEUE_EPPRELE'
EXPORTING
pernr = '00000302'
infty = '0002'.
This way itxex field is treated correctly and if existed on that record, will remain intact. However, this method will not work for updating the long text itself, for that you must use object-oriented way, methods of class CL_HRPA_INFOTYPE_CONTAINER.

Related

Parameter type error on BAPI_OBJCL_GETDETAIL call?

lv_objectkey2 = ls_mseg-matnr.
"Transport Category
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = lv_objectkey2
objecttable = 'MARA'
classnum = 'Z_MATERIAL_CLASS'
classtype = '001'
TABLES
allocvaluesnum = lt_allocvaluesnum2
allocvalueschar = lt_allocvalueschar2
allocvaluescurr = lt_allocvaluescurr2
return = lt_return2.
READ TABLE lt_allocvaluesnum2 INTO ls_valnum2 WITH KEY charact= 'Z_ADR_QUANTITY'.
IF sy-subrc = 0.
lv_adr_quan = ls_valnum2-value_from + lv_adr_quan.
WRITE: lv_adr_quan TO ls_item-ADR_QUAN EXPONENT 0 DECIMALS 2.
* CONDENSE ls_item-ADR_QUAN.
ENDIF.
Here is my problem : The program gives me that problem : "ADR_QUAN" must be a character-type field (data type C, N, D or T).
I need your opinions to fix the issue or solutions.
CONDENSE Statement works only for the character-like variables. Here, ls_item-ADR_QUAN field is of type Float, That's why you're getting that error.
You can go through the attached documentation link for CONDENSE statement.
CONDENSE Documentation
Even if you want to perform CONDENSE then first, you've to assign ls_item-ADR_QUAN to a character-like variable.

BAPI_CONTRACT_CREATE error "Enter material number or account assignment category"

I am using the BAPI_CONTRACT_CREATE to upload the contract orders in ME31K.
For Testing purpose I maintained all the parameters which is relevant to above BAPI in SE37.
But system is showing the error even though material code & and all other fields are maintained in respective fields.
Please find the attached screenshot for the reference.
My 2 cents, as this kind of error is frequent in many BAPI functions.
BAPI functions frequently have their parameters doubled, for instance one named ITEM and another one named accordingly and suffixed with X (ITEMX). This additional parameter has the exact same fields, with the same name but with a one-character length which can take the value either ' ' or 'X'.
'X' is to indicate that the corresponding field in ITEM must be changed. The interest of these doubled parameters can be better understood in BAPI used to change an existing object, to force a field to be changed to an empty value. Fields with a empty value mean "no change".
Example code:
DATA: items TYPE TABLE OF BAPIMEOUTITEM,
items_x TYPE TABLE OF BAPIMEOUTITEMX.
items = VALUE #(
( item_no = '00010' material = 'MAT01' )
( item_no = '00020' material = 'MAT02' ) ).
items_x = VALUE #(
( item_no = '00010' material = 'X' )
( item_no = '00020' material = 'X' ) ).
...
CALL FUNCTION 'BAPI_CONTRACT_CREATE'
TABLES
item = items
itemx = items_x
...

I don't understand how READ TABLE inside LOOP works

In my code I need to iterate inside a loop, and for each iteration in the loop I have to fill in the data whose values ​​are different in certain cells.
Reading the sap documentation I have come to the conclusion that what I need is to use a read table to fill for each iteration into a working area that later I'll treat.
I have declarated the following tables:
it_sap with the content of a join from VBRK and VBRP tables
wa_sap as working area
it_ext with content from an another join from an external database
wa_ext as working area.
This is how my loop looks actually like:
LOOP AT it_sap INTO wa_sap.
wa_sap-tipo_documento = wa_sap-xblnr+2(1). " Linea
tiket = wa_sap-xblnr+9(7).
creationyear = wa_sap-fkdat+0(4).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = tiket
IMPORTING
output = tiket.
CONCATENATE creationyear '/' wa_sap-vkorg wa_sap-xblnr+7(2) '/' tiket INTO wa_sap-codalb.
"CLEAR position.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_sap-posnr
IMPORTING
output = position.
READ TABLE it_ext INTO wa_ext
WITH KEY codalb = wa_ext-codalb
tipo_documento = wa_ext-tipo_documento.
IF sy-subrc = 0.
wa_sap-import_total = wa_ext-import_total.
wa_sap-import = wa_ext-import.
wa_sap-price = wa_ext-price.
wa_sap-price_total = wa_ext-price_total.
wa_sap-disccount = wa_ext-disccount.
wa_sap-quantity = wa_ext-quantity.
MODIFY it_sap FROM wa_sap.
IF wa_sap-importe_total <> wa_sap-netwr. "AND position = 1 .
APPEND wa_sap TO it_results.
ENDIF.
ENDIF.
ENDLOOP.
How does it work? I understand that by using the conditional sy-subrc = 0 I can see if the previous statement gives true or false but I don't quite understand how it works by using READ instead SELECT steament.
Thank you guys!
LOOP AT iterates over all rows of an internal table.
READ TABLE retrieves at most one row from an internal table.
sy-subrc provides you details about how well the previous statement worked. Its values differ with the statement. In case of READ TABLE, it tells you whether a row was found (= 0) or not (<> 0). The IF sy-subrc = 0 after your READ TABLE thus means "if you found such a row".
It's hard to understand what your code is supposed to do and whether it does that correctly without some helpful sample data. As József Szikszai points out in the comments to your question, the READ TABLE's conditions rely on wa_ext, which is never filled in your sample code, so at first glance this looks like it's not working at all or your sample does not include some initialisation code.

cmd_ei_api=>maintain_bapi to update kna1 table field (ICMSTAXPAY)

I have a requirement to update this field ICMSTAXPAY in KNA1 table using my custom report. So, I tried using cmd_ei_api=>maintain_bapi to update the table. But once I run the program, that particular field is not updated and I don't get any error messages too.
My logic:
Read the KNA1 entries.
Edit the required field to my value.
Pass mandatory data to HEADER for update.
Pass my new KNA1 entries to CENTRAL_DATA.
Read data from table:
CALL METHOD cmd_ei_api_memory=>get_global_kna1
EXPORTING
iv_kunnr = <lfs_final>-kunnr
IMPORTING
es_kna1_old = ls_old.
Change the value of field:
ls_old-icmstaxpay = 9.
MOVE-CORRESPONDING ls_old TO ls_customer-central_data-central-data.
Assign header data:
ls_customer-header-object_instance-kunnr = <lfs_final>-kunnr.
ls_customer-header-object_task = 'U'.
Add all the above to the master data structure:
APPEND ls_customer TO lt_customers[].
ls_master_data-customers = lt_customers[].
Pass the data and update to table:
cmd_ei_api=>initialize( ).
LOOP AT lt_customers INTO ls_customer.
cmd_ei_api=>lock( iv_kunnr = ls_customer-header-object_instance-kunnr ).
ENDLOOP.
" Update Customer with CMD_EI_API
CALL METHOD cmd_ei_api=>maintain_bapi
EXPORTING
iv_test_run = space
is_master_data = ls_master_data
IMPORTING
es_message_defective = ls_message_defective.
IF ls_message_defective IS INITIAL.
BREAK-POINT.
COMMIT WORK.
ELSE.
BREAK-POINT.
ENDIF.
LOOP AT lt_customers INTO ls_customer.
cmd_ei_api=>unlock( iv_kunnr = ls_customer-header-object_instance-kunnr ) .
ENDLOOP.
When I debug, I can see that the entry that is being fetched for update is the old entry that is present in the current memory.
Please let me know if i am doing something wrong while passing the value to the table.
You need including DATAX with X for all fields that you need change.
DATA: ls_datax TYPE cmds_ei_vmd_central_data_xflag.
ls_datax-icmstaxpay = 'X'.
MOVE ls_datax TO ls_customer-central_data-central-datax.
And thanx for your question, helped me with find this methody :)

How to get long texts of FI held documents?

I need to get the particulars/long text of FI held documents. I tried the 'read_text' function module but had no luck since the held document has the temporary document number.
I tried looking for data in STXL and STXH tables, I also tried the function modules in FM group FTXT and STXD but had no luck.
Any other method to achieve that goal?
First of all, you need the temporary document number which can be get either from F-43 itself or from RFDT table.
In field SRTFD you should separate it from username.
Then run READ_TEMP_DOCUMENT FM, after running it you should have your texts in ABAP memory.
To get them use GET_TEXT_MEMORY.
ls_uf05a-tempd = '0012312356'. "doc number
ls_uf05a-unamd = 'JOHNDOE'. "username
CALL FUNCTION 'READ_TEMP_DOCUMENT'
EXPORTING
I_UF05A = ls_uf05a
TABLES
T_BKPF = lt_bkpf
T_BSEC = lt_bsec
T_BSED = lt_bsed
T_BSEG = lt_bseg
T_BSET = lt_bset
T_BSEZ = lt_bsez
.
DATA: lt_texts TYPE TABLE OF TCATALOG,
t_tline TYPE STANDARD TABLE OF tline,
memory_id(30) VALUE 'SAPLSTXD'.
CALL FUNCTION 'GET_TEXT_MEMORY'
TABLES
TEXT_MEMORY = lt_texts.
READ TABLE lt_texts ASSIGNING FIELD-SYMBOL(<cat>) WITH KEY tdobject = 'BELEG'
tdid = '0001'
tdspras = 'E' BINARY SEARCH.
IF sy-subrc = 0.
memory_id+8(6) = <cat>-id.
ENDIF.
IMPORT tline = t_tline FROM MEMORY ID memory_id.
LOOP AT t_tline ASSIGNING FIELD-SYMBOL(<tline>).
WRITE: <tline>-tdline. "showing the texts
ENDLOOP.