Set text field in screen visible again after user command - abap

in my PBO Module I have something like this:
LOOP AT SCREEN.
IF screen-name EQ 'LBL_TEST'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
I want to set 'LBL_TEST' visible again after some User-Command in the PAI-Module. How can I do it?
Best regards,
Timur

You have to do it in PBO. You can set a global parameter when your operation completed and then check it. Like:
DATA: gv_checker.
PROCESS AFTER INPUT.
case ok_code.
when 'some_opp'.
gv_checker = 'X'.
endcase.
PROCESS BEFORE OUTPUT.
LOOP AT SCREEN.
IF screen-name EQ 'LBL_TEST'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDIF.
if IF screen-name EQ 'LBL_TEST' and gv_checker = 'X'.
screen-invisible = '0'.
MODIFY SCREEN.
endif.
ENDLOOP.

Can't you check the value of sy-ucomm in the PBO? (I haven't checked myself, and don't know by heart, this is why I am asking.) If not, you can declare a global variable:
DATA: gv_ucomm TYPE sy-ucomm.
Move the value of sy-ucomm into this global variable in the PAI:
gv_ucomm = sy-ucomm.
And check the value of it in the PBO:
IF gv_ucomm EQ '...'.
... "turn on field
ELSE.
... "turn off field
ENDIF.

Related

How to create a txt-file on the application server filled with an internal table?

I'm learning ABAP at the moment and got the task to build a function that creates a .txt file or a .csv file from an internal table and save it on the application server.
I know you can use, for example, GUI_DOWNLOAD for that, but the task is to build my own function to do that.
So I got an internal table filled and I want that to be saved as .txt file on the AS. I'm coding in Eclipse, BTW.
Anybody has an idea how to do that, using a function?
EDIT:
Here's what I tried already:
I created a function in the function builder. On the import parameters I put a parameter with the name "lv_mytab" with type table.
The source code of my function looks like this:
*"-------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(LV_MYTAB) TYPE TABLE
*"-------------------------------------------------------------------
DATA(myfile) = '/usr/sap/S42/data/textfile.txt'.
OPEN DATASET myfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT WITH SMART LINEFEED.
LOOP AT lv_mytab into lt_table.
TRANSFER lt_table to myfile.
CLOSE DATASET myfile.
In my program I tried calling the function like this:
CALL FUNCTION 'EXPORT_TXT_CSV_MR'
EXPORTING
lv_mytab = lt_summe.
lt_summe is the internal table I want to be exported as txt or csv.
Something like this:
OPEN DATASET lv_p_app FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT gt_error INTO gs_final.
TRANSFER gs_final TO lv_p_app.
ENDLOOP.
CLOSE DATASET lv_p_app.
ENDIF.
More samples here https://answers.sap.com/questions/3704234/download-internal-table-onto-the-application-serve.html
Okay with the help of a fellow student I got it working.
Heres the solution I found:
Code source of the function:
FUNCTION EXPORT_TXT_CSV_MR.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(S_FILENAME) TYPE STRING
*" CHANGING
*" REFERENCE(GT_MYTAB) TYPE STANDARD TABLE
*" REFERENCE(GD_VERARBEITUNG) TYPE INT4
*"----------------------------------------------------------------------
DATA:
ld_filename TYPE string,
ld_datei type standard table of sbook,
ld_Zeile like line of ld_datei,
gd_useraction TYPE i,
lt_Ausgabe TYPE STANDARD TABLE OF sbook.
CONCATENATE '/usr/sap/S42/data/' s_filename into ld_filename.
IF gd_Verarbeitung = 1.
ld_datei = gt_mytab.
OPEN DATASET ld_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT ld_datei into ld_Zeile.
Data(ld_string) = | Partnernummer: { ld_Zeile-customid } Betrag: { ld_Zeile-forcuram } Waehrung: { ld_Zeile-forcurkey } Name: { ld_Zeile-passname }|.
Transfer ld_string to ld_filename.
ENDLOOP.
Close dataset ld_filename.
ElseIF gd_Verarbeitung = 2.
ld_datei = gt_mytab.
*ld_filename = '/usr/sap/S42/data/CSVFile_MR.csv'.
Open Dataset ld_filename for output in text mode encoding default with SMART LINEFEED.
LOOP AT ld_datei into ld_Zeile.
ld_string = | Partnernummer: { ld_Zeile-customid } Betrag: { ld_Zeile-forcuram } Waehrung: { ld_Zeile-forcurkey } Name: { ld_Zeile-passname }|.
Transfer ld_string to ld_filename.
ENDLOOP.
Close dataset ld_filename.
ENDIF.
ENDFUNCTION.
And in my program I call it like this:
if p_txt = 'X'.
ld_txtcsv = 1.
CALL FUNCTION 'EXPORT_TXT_CSV_MR'
EXPORTING
s_filename = 'TXTFile_MR.txt'
CHANGING
gt_mytab = lt_summe
gd_verarbeitung = ld_txtcsv.
clear ld_txtcsv.
endif.
if p_csv = 'X'.
ld_txtcsv = 2.
CALL FUNCTION 'EXPORT_TXT_CSV_MR'
EXPORTING
s_filename = 'CSVFile_MR.csv'
CHANGING
gt_mytab = lt_summe
gd_verarbeitung = ld_txtcsv.
clear ld_txtcsv.
ENDIF.
Thanks for all of your help! I got it now! :)

Add new emails Customer at XD02 from CALL METHOD cmd_ei_api=>maintain_bapi

I need to add a new email address on customers in XD02 from an xls.
That's all ok, but, when I CALL METHOD cmd_ei_api=>maintain_bapi
this really change the email but delete all the emails on XD02, and it's not what I want, I want to add a new email put this one default, but I want to keep the old ones.
My code :
FORM data_to_bapi.
DATA: gs_correct TYPE cmds_ei_main,
gt_customers TYPE cmds_ei_main,
gs_address TYPE bapiad1vl,
gs_addressx TYPE bapiad1vlx,
gs_company_code_st TYPE cmds_ei_company,
gs_company_code TYPE cmds_ei_cmd_company,
gt_smtp TYPE cvis_ei_smtp_t,
gs_smtp LIKE LINE OF gt_smtp,
gs_comm TYPE cvis_ei_cvi_communication,
gs_customers TYPE cmds_ei_extern,
gs_defective TYPE cmds_ei_main,
gs_msg_correct TYPE cvis_message,
gs_msg_error TYPE cvis_message,
iv_test_run TYPE c.
LOOP AT lt_data INTO wa_data.
"Controlo
gs_customers-header-object_instance-kunnr = wa_data-kunnr. "kunnr
gs_customers-header-object_task = 'U'. "Update this kunnr
gs_smtp-contact-task = 'I'. " Insert New Email
gs_smtp-contact-data-e_mail = wa_data-email. " New email
gs_smtp-contact-datax-e_mail = 'X'.
APPEND gs_smtp TO gt_smtp.
gs_comm-smtp-smtp = gt_smtp[].
gs_customers-central_data-address-communication = gs_comm.
gs_customers-central_data-address-task = 'I'. " Insert new communication
APPEND gs_customers TO gt_customers-customers.
**********************************************************************
* CALL BAPI *
**********************************************************************
CHECK gt_customers-customers IS NOT INITIAL.
gv_collect_messages = abap_true.
cmd_ei_api=>initialize( ).
iv_test_run = ' '.
CALL METHOD cmd_ei_api=>maintain_bapi
EXPORTING
iv_test_run = iv_test_run
iv_collect_messages = gv_collect_messages
is_master_data = gt_customer
" Master Data
IMPORTING
es_master_data_correct = gs_correct
es_message_correct = gs_msg_correct
es_master_data_defective = gs_defective
es_message_defective = gs_msg_error.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
CLEAR wa_data.
ENDLOOP.
ENDFORM. "data_to_bapi
Thanks !

How to extract the value of the field on user-command(click) for interactive ALV?

The below code is the form which will pop up the new window after clicking on the hotspot enabled field. I want to print the value of the field (hotspot enabled) that is clicked.
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
ENDFORM.
I guess you talk about the ALV Grid. So you use a FM called REUSE_ALV_GRID_DISPLAY. There is a exporting parameter called I_callback_user_command. In this parameter you have to set the form name of your program. For Example:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_bypassing_buffer = 'X'
it_fieldcat = lt_fieldcat
i_callback_program = sy-repid
i_save = 'A'
i_callback_user_command = 'USER_COMMAND'
is_variant = ls_variant
TABLES
t_outtab = lt_qmel_mat
EXCEPTIONS
program_error = 1
OTHERS = 9.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
And the Form:
FORM user_command USING rf_ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA: lv_qmnum TYPE qmnum.
CASE selfield-fieldname.
WHEN 'QMNUM'.
"Code
ENDCASE.
ENDFORM.
I hope that helps you.

SAP HR OM BAdI does not detecting IN_UPDATE changes

We have implemented BADI ZHR_INT_BAD_OM_INFTY and Method IN_UPDATE. Now when some users save their OM work the IN_UPDATE method is not triggered.
The problem with debugging this is that when you go into abap debugger "stuff" in the background gets committed.
Our goal is to have a list of recent OM changes for delta detection.
Example of the code we have implemented:
DATA:
lw_old_image LIKE LINE OF old_image,
lw_new_image LIKE LINE OF new_image,
ls_object TYPE hrobject.
"-- Check if there is anything interesing in the old image
LOOP AT old_image INTO lw_old_image
WHERE infty IN me->get_range_infotypes( )
AND begda LE sy-datum
AND endda GE sy-datum.
MOVE-CORRESPONDING lw_old_image TO ls_object.
"-- If an object has been detected, trigger the refresh
TRY.
zhr_cl_int_person_masterdata=>trigger_om_object_changed( zhr_cl_om_object=>get( im_plvar = ls_object-plvar
im_otype = ls_object-otype
im_objid = ls_object-objid ) ).
CATCH zcx_hr_om. " " Base class for OM objects
ENDTRY.
ENDLOOP.
"-- If nothing found, check if there is anything interesting in the new image
IF ls_object IS INITIAL.
LOOP AT new_image INTO lw_new_image
WHERE infty IN me->get_range_infotypes( )
AND begda LE sy-datum
AND endda GE sy-datum.
MOVE-CORRESPONDING lw_new_image TO ls_object.
"-- If an object has been detected, trigger the refresh
TRY.
zhr_cl_int_person_masterdata=>trigger_om_object_changed( zhr_cl_om_object=>get( im_plvar = ls_object-plvar
im_otype = ls_object-otype
im_objid = ls_object-objid ) ).
CATCH zcx_hr_om. " " Base class for OM objects
ENDTRY.
ENDLOOP.
ENDIF.

how metamacro_if_eq works in extobjc

Read at the source code https://github.com/jspahrsummers/libextobjc/blob/master/extobjc/metamacros.h#L158
// expands to true
metamacro_if_eq(0, 0)(true)(false)
when is expand the macro metamacro_if_eq(0, 0) manually, i get the following
metamacro_if_eq0(0) (true) (false)
continue expanding.
metamacro_if_eq0_0() (true) (false)
go on.
metamacro_consume_ (true) (false)
metamacro_consume is defined as:
#define metamacro_consume_(...) // why nothing here ?
then how can I get the expected value of "true" ?
Your production is incorrect. The operations go like this:
metamacro_if_eq(0, 0)(true)(false)
metamacro_concat(metamacro_if_eq, 0)(0)(true)(false)
metamacro_concat_(metamacro_if_eq, 0)(0)(true)(false)
metamacro_if_eq0(0)(true)(false)
metamacro_concat(metamacro_if_eq0_, 0)(true)(false)
metamacro_concat_(metamacro_if_eq0_, 0)(true)(false)
// You made a mistake at this point.
metamacro_if_eq0_0(true)(false)
true metamacro_consume_(false)
true
After the second round of concatenation, true becomes the argument to metamacro_if_eq0_0(). The argument(s) to that macro is/are left in its place. metamacro_consume_() takes any numer of arguments and resolves to nothing.