BDCDATA with SELECT-OPTION - abap

I'm calling a report with CALL TRANSACTION. I don't want to use SUBMIT. I need to give values to a SELECT-OPTIONS opening the button and excluding value 'X'. This is the code that I found from registration
ls_bdcdata-fnam = 'BDC_OKCODE'.
ls_bdcdata-fval = '=%020'.
APPEND ls_bdcdata TO lt_bdcdata.
CLEAR ls_bdcdata.
ls_bdcdata-dynbegin = 'X'.
ls_bdcdata-dynpro = '3000'.
ls_bdcdata-program = 'SAPLALDB'.
APPEND ls_bdcdata TO lt_bdcdata.
CLEAR ls_bdcdata.
ls_bdcdata-fnam = 'BDC_OKCODE'.
ls_bdcdata-fval = '=NOSV'.
APPEND ls_bdcdata TO lt_bdcdata.
CLEAR ls_bdcdata.
ls_bdcdata-fnam = 'BDC_SUBSCR'.
ls_bdcdata-fval = 'SAPLALDB 3010SCREEN_HEADER'.
APPEND ls_bdcdata TO lt_bdcdata.
CLEAR ls_bdcdata.
ls_bdcdata-dynbegin = 'X'.
ls_bdcdata-dynpro = '3000'.
ls_bdcdata-program = 'SAPLALDB'.
APPEND ls_bdcdata TO lt_bdcdata.
CLEAR ls_bdcdata.
ls_bdcdata-fnam = 'BDC_OKCODE'.
ls_bdcdata-fval = '=ACPT'.
APPEND ls_bdcdata TO lt_bdcdata.
CLEAR ls_bdcdata.
ls_bdcdata-fnam = 'BDC_SUBSCR'.
ls_bdcdata-fval = 'SAPLALDB 3030SCREEN_HEADER'.
APPEND ls_bdcdata TO lt_bdcdata.
CLEAR ls_bdcdata.
ls_bdcdata-fnam = 'RSCSEL_255-SLOW_E(01)'.
ls_bdcdata-fval = 'X'.
APPEND ls_bdcdata TO lt_bdcdata.
CLEAR ls_bdcdata.
The SELECT-OPTIONS is identified by
ls_bdcdata-fval = '=%020'.
But when I added a new SELECT-OPTIONS to the called report this numeration changed. Can I have the numeration value from the name of the SELECT-OPTIONS and not from this '=%020' value? So I can prevent new changes of the numeration when I will add new SELECT-OPTIONS.

Related

Download an Excel document built with class CL_XLSX_DOCUMENT

My program below creates an Excel document built with the class CL_XLSX_DOCUMENT, which contains two sheets.
How can I download the Excel document on my laptop ?
lo_worksheetpart ?= lo_workbookpart->get_worksheetparts( )->get_part( lv_line_no_loop ).
lo_worksheetpart_1 ?= lo_workbookpart->add_worksheetpart( ).
lv_sheetxml = lo_worksheetpart->get_data( ).
lv_sheetxml_2 = lo_worksheetpart_1->get_data( ).
lo_sharedstringspart = lo_workbookpart->get_sharedstringspart( ).
lv_sharedxml = lo_sharedstringspart->get_data( ).
"Parse and replace
if lt_nameval is not initial.
lv_resultxml = update_shared_string_1(
EXPORTING
iv_xml = lv_sharedxml
iv_node = co_shared_string
it_nameval = lt_nameval ).
"write new excel
lo_sharedstringspart->feed_data( lv_resultxml ).
lv_resultxml = update_sheet_data_1(
EXPORTING
iv_xml = lv_sheetxml
iv_node = co_sheet_data
it_days = lt_days
it_nameval = lt_nameval ).
"write new excel
lo_worksheetpart->feed_data( lv_resultxml ).
endif.
I use the following:
DATA:
lv_fsize TYPE i,
lt_data TYPE tsfixml,
lv_resultxml TYPE xstring.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_resultxml
IMPORTING
output_length = lv_fsize
TABLES
binary_tab = lt_data.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = lv_fsize
filetype = 'BIN'
filename = 'C:\Temp\filename.xlsx
CHANGING
data_tab = lt_data

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 !

Create outbound delivery with different shipping address

I've searched for days and found nothing. My problem is, that I have to create a return delivery out of an QM-Report. Everything works fine.
However, the customer wants to change the delivery address manually.
Flow:
QM02 (QM-Report) => Return order with BAPI_PO_CREATE1 (different address works fine) => Delivery with BAPI_OUTB_DELIVERY_CREATE_STO (different address from PO not working)
My question:
Is there a possibility to change the delivery address of the outbound delivery? Do I have to implement a BADI or is there a simple solution?
If anything is missing, I will update the question.
Function BAPI_OUTB_DELIVERY_CREATE_STO allows you to create deliveries from PO but you can't handle many of the delivery fields.
After you have created the deliveries, you should use WS_DELIVERY_UPDATE_2 function to update any field.
This is not a BAPI, and consequently it is not well documented, but is widely used for these changes.
Best regards
UPDATE
Here's a snippet:
ls_vbkok-vbeln_vl = <delivery number>.
ls_partners-vbeln_vl = ls_vbkok-vbeln_vl.
ls_partners-parvw = 'WE'.
ls_partners-parnr = <partner number>.
ls_partners-updkz_par = 'U'.
ls_partners-stras = <new street address>.
append ls_partners to lt_partners.
call function 'WS_DELIVERY_UPDATE_2'
exporting
vbkok_wa = ls_vbkok
synchron = 'X'
commit = 'X'
delivery = ls_vbkok-vbeln_vl
tables
vbpok_tab = lt_vbpok
it_partner_update = lt_partners
prot = lt_prot.
if lt_prot[] is not initial.
" handle error message here
endif.
if you need to make a commit and you can do it after the 'WS_DELIVERY_UPDATE_2' , try to call it in a new task.
for exemple :
call function 'WS_DELIVERY_UPDATE_2' STARTING NEW TASK task
PERFORMING return_fm ON END OF TASK
exporting
vbkok_wa = ls_vbkok
synchron = 'X'
commit = ' '
delivery = ls_vbkok-vbeln_vl
tables
vbpok_tab = lt_vbpok
it_partner_update = lt_partners
prot = lt_prot.
*your code
WAIT UNTIL get_executed <> space.
FORM return_fm USING i_taskname.
*your code
get_executed = 'X'.
ENDFORM.

Call AFIP MTXCA web-service properly from SAP ECC

I am trying to call the AFIP WebService MTXCA directly from SAP ECC.
There is no problem with that. The thing is when I try to get the TOKEN and SIGN from the first WS
https://wsaahomo.afip.gov.ar/ws/services/LoginCms?WSDL
I can not sign the XML to build the right CMS to get the proper answer from AFIP.
cl_secxml_helper=>upload_file( EXPORTING filename = p_xml
IMPORTING bindata = DATA(lv_xml) ).
DATA(lo_object) = cl_sec_sxml_dsignature=>create_reader_instance( if_input = lv_xml ).
lo_object->m_ssf_hash_algorithm = 'SHA1'.
lo_object->m_dsig_hash_algorithm = 'SHA1'.
lo_object->m_dsig_method = 'RSA'.
lo_object->m_signature_ns_prefix = ''.
lo_object->sign_xml( EXPORTING if_ssf_app = 'OAUTH'
if_add_keyinfo = abap_true
if_add_keyinfo_ex = abap_true
IMPORTING ef_signature_xml = DATA(lf_result)
es_signer = DATA(ls_signer) ).
lo_object->embed_signature( EXPORTING if_xml = lv_xml
if_signature = lf_result
if_embed_as_child = abap_true
if_embed_at_end = abap_true
is_signer = ls_signer
IMPORTING ef_result = lf_result ).
cl_soap_xml_helper=>xml_show( xdoc = lf_result ).
ls_request-in0 = lf_result.

How to access project name from a query of type portfolioitem

I am trying to match Project name in my query and also trying to print the name of the project associated with each feature record. I know there are plenty of answers but I couldn't find anything that could help me. I am trying to do something like this:
pi_query.type = "portfolioitem"
pi_query.fetch="Name,FormattedID,Owner,c_ScopingTeam,c_AspirationalRelease,c_AssignedProgram,Tags"
#To be configured as per requirement
pi_query.project_scope_up = false
pi_query.project_scope_down = false
pi_query.order = "FormattedID Asc"
pi_query.query_string = "(Project.Name = \"Uni - Serviceability\")"
pi_results = #rally.find(pi_query)
I am trying to match the project name but it simply doesn't work, I also tried printing the name of the project, i tried Project.Name, Project.Values or simply Project. But it doesn't work. I am guessing it is because of my query type which is "portfolioItem" and I can't change my type because I am getting all other attribute values correctly.
Thanks.
Make sure to fetch Project, e.g: feature_query.fetch = "Name,FormattedID,Project"
and this should work:
feature_query.query_string = "(Project.Name = \"My Project\")"
Here is an example where a feature is found by project name.
require 'rally_api'
#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "create story in one project, add it to a feature from another project"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"
# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user#co.com"
config[:password] = "secret"
config[:workspace] = "W"
config[:project] = "Product1"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
#rally = RallyAPI::RallyRestJson.new(config)
obj = {}
obj["Name"] = "new story xyz123"
new_s = #rally.create("hierarchicalrequirement", obj)
query = RallyAPI::RallyQuery.new()
query.type = "portfolioitem"
query.fetch = "Name,FormattedID,Project"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/12352608129" }
query.query_string = "(Project.Name = \"Team Group 1\")"
result = #rally.find(query)
feature = result.first
puts feature
field_updates={"PortfolioItem" => feature}
new_s.update(field_updates)