on 04-10-2013 9:49 AM
Hi all,
i've extended the Web-Dynpro Componente /SAPSRM/WDC_DODC_SC_GAF
In this extension i collect some SC-Items an create an new SC with status "saved".
If i close my extension... i want to go automatic to the second step. I know the SC-guid, an the SC-number. How can i call these second view with my saved SC-items
Thanks in advance,
with regards
--Bernward Henkel
Hi Bernward,
if you want to add a number of positions to the opened SC and you
create an new SC with status "saved".
It is already wrong. In SC in 4 steps you already have SC instance buffered, and you should use it.
By closing your extension you should add your positions to SC Buffer.
Just an exmaple, how you can get current SC.
DATA lo_task TYPE REF TO /sapsrm/if_cll_task_container.
DATA lo_bom TYPE REF TO /sapsrm/if_cll_bom_sc.
DATA lo_sc TYPE REF TO /sapsrm/if_pdo_bo_sc_adv.
DATA lv_guid TYPE bbp_guid.
DATA lt_item TYPE bbpt_pd_sc_item_d.
lo_task = /sapsrm/cl_ch_wd_taskcont_fact=>get_task_container_instance( ). " Task Container
lo_bom = lo_task->get_bom_sc( ). " Get reference to SC Mapper
lv_guid = lo_bom->/sapsrm/if_cll_bo_mapper~get_bo_guid( ). " Get SC GUID
lo_sc = /sapsrm/cl_pdo_factory_sc_adv=>get_buffered_instance( lv_guid ). " Get SC Instance
IF lo_sc IS BOUND.
" Here is your code
ENDIF.
In lo_sc should have your current SC instance. Then you can add items via method
lo_sc->/sapsrm/if_pdo_bo_sc~add_item or add_limit_item or add_service_item - what you need...
Event for Navigation to the second step you can try to realize via CL_FPM class. Here I'm not sure, but should work.
DATA lo_fpm type ref to if_fpm.
lo_fpm = cl_fpm_factory=>get_instance();
lo_fpm->raise_event_by_id( cl_fpm_event=>gc_event_next_step );
Best Regards
Konstantin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Konstantin,
thx for anwer. Looks like your code work... but 😉
When i try to navigate the system dumped (no item are available!?). It is verry interesting because it is the same result as when i press the "next step" button without select items form our MDM catalog.
Maybe you have an idea what is wrong!
Thanks...
Best Regards
--Bernward
Hi Bernward,
how do you add items? You have written, that you have "saved" SC. If you add positions via old functions like BBP_PD_SC_... it will not be accepted by PDO Layer in WebDynpro.
After adding positions via new functionality (classes, methods) - don't forget to trigger SUBMIT_UPDATE method.
Best Regards
Konstantin
Hi Konstantin,
yep... that works. I'm using thes code...but 🙂
lo_sc = /sapsrm/cl_pdo_factory_sc_adv=>get_buffered_instance( lv_guid ). " Get SC Instance
IF lo_sc IS BOUND.
LOOP AT it_item INTO ls_item.
TRY.
lo_sc->/sapsrm/if_pdo_bo_sc~add_item( EXPORTING iv_uname = sy-uname is_item = ls_item ).
CATCH /sapsrm/cx_pdo_no_authorizatio .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_abort .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_incons_user .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_curr_error .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_cat_not_allowed .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_prd_not_found .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_prd_not_unique .
lv_error = abap_true.
ENDTRY.
ENDLOOP.
ENDIF.
data lv_co_message_handler TYPE REF TO /SAPSRM/IF_PDO_MSG_CONSUMER.
lo_sc->/SAPSRM/IF_PDO_BASE~SUBMIT_UPDATE( CHANGING co_message_handler = lv_co_message_handler ).
When i debug the component /SAPSRM/WDC_UI_SC_DOTC_BD with view V_SC_DOTC_BASIC in the "Post-Exit" WDDOMODIFYVIEW hookmethod... i read the ShoppingCart and find my "hommade" items. But it looks like, that the COMP_CONTEXT [ITEMS] has no entry. That's the reason why it dumped.
What must i do, which class/method must i call that these component holds my items !?
Do u have any idea ?
Best regards
--Bernward
Hi Bernward,
please try following. In the mentioned view go to tab Attributes and find a mapper class MO_DOTM_SC_I_BD (responsible for mapping from SC to WDA and backwards).
Call it's method /SAPSRM/IF_CLL_MAPPER~REFRESH( )
It should make a mapping from SC to WDA.
Best Regards
Konstantin
P.S. don't forget reward points if helpful.
Hi Konstantin,
u will earn all points + 1.000.000 extra points 😉
I found out why the dump occured. It was an homemade extension in which these specific constellation has no entrys. I fixed that line and the dump is solved. The dump and my current problem have a glue... in both situation i have no item data available. The ITEMS_TABLE in VIEW V_SC_DOTC_BASIC is empty... but i can see some data from header (TOTAL_VALUE). And when i use the CHECK-BUTTON i receive all messages to all items.
Don't know what i've to do to set all items correct in the context. Looks like the SC instance buffer, you talk about in your first answer, is available but someone/something didn't filled in the item data into the context 😉
I set a breakpoint in hookmethod WDDOINIT of VIEW V_SC_DOTC_BASIC where itried to find out if my items current available. I saw nothing unusually.
And i break in POST-EXIT of WDDOMODIFYVIEW and read all my expected ITEMS from the SC.
So...why can't i see the ITEMS in the table ?
Best Regards and an wonderful weekend...
--Bernward
Hi Konstantin,
i found out that when i save the SC after update... i will be in DISPLAY mode in View V_SC_DOTC_BASIC. That's wenn i didn' see the items too, but when i click the EDIT mode i see all my missing items. It's a workaround but it works.
********************************************************************** * Submit Update und * speichdrn des SC <== muss dann im nächsten Schritt auf "Bearbeiten" gesetzte werden ! ********************************************************************** TRY. lo_sc->/sapsrm/if_pdo_base~submit_update( CHANGING co_message_handler = lv_co_message_handler ). lo_sc->/sapsrm/if_pdo_base~save( CHANGING co_message_handler = lv_co_message_handler ). CATCH /sapsrm/cx_pdo_wrong_mode . lv_error = abap_true. CATCH /sapsrm/cx_pdo_abort . lv_error = abap_true. ENDTRY.
Thanks for your help...you are my hero 🙂
Best regards
HI Bernward,
thx for feedback.
I would say, you should not use BBP_.... functions anymore. They are obsolet... Mentioned class lo_sc has all methods you need (incl. get_detail)
What for items, have you tried /SAPSRM/IF_CLL_MAPPER~REFRESH( ) method?
I'm not really sure and it's hard to say, without seeing your code.
Additionally, when you call SUBMIT_UPDATE - check the messages of your lv_co_message_handler.
Best Regards
Konstantin
For all who want's to know what we are talking about...
Here is my code which is now working. Thx again to Konstantin...
METHOD onactioncreate_sc .
**********************************************************************
* Möglichkeit die GUID einer bestellung aus den zur verfügung stehenden
* Methoden zur ermitteln.
**********************************************************************
* lo_task = /sapsrm/cl_ch_wd_taskcont_fact=>get_task_container_instance( ). " Task Container
* lo_bom = lo_task->get_bom_sc( ). " Get reference to SC Mapper
* lv_guid = lo_bom->/sapsrm/if_cll_bo_mapper~get_bo_guid( ). " Get SC GUID
*
**********************************************************************
DATA lo_task TYPE REF TO /sapsrm/if_cll_task_container.
DATA lo_bom TYPE REF TO /sapsrm/if_cll_bom_sc.
DATA lo_sc TYPE REF TO /sapsrm/if_pdo_bo_sc_adv.
DATA lv_guid TYPE bbp_guid.
DATA lv_guid2 TYPE bbp_guid.
DATA lt_item_d TYPE bbpt_pd_sc_item_d.
DATA ls_item_d TYPE bbp_pds_sc_item_d.
DATA lo_fpm TYPE REF TO if_fpm.
DATA lv_co_message_handler TYPE REF TO /sapsrm/if_pdo_msg_consumer.
DATA lv_eo_meta_data_handler TYPE REF TO /sapsrm/if_pdo_meta_consumer.
DATA lo_nd_item TYPE REF TO if_wd_context_node.
DATA lo_el_item TYPE REF TO if_wd_context_element.
DATA it_item TYPE wd_this->elements_item.
DATA lt_item TYPE wd_this->elements_item.
DATA lo_nd_header TYPE REF TO if_wd_context_node.
DATA lo_el_header TYPE REF TO if_wd_context_element.
DATA is_header TYPE wd_this->element_header.
DATA lo_nd_selection TYPE REF TO if_wd_context_node.
DATA lo_el_selection TYPE REF TO if_wd_context_element.
DATA ls_selection TYPE wd_this->element_selection.
DATA lv_kostl TYPE wd_this->element_selection-kostl.
DATA lv_saknr TYPE wd_this->element_selection-saknr.
DATA lo_nd_tag_visible TYPE REF TO if_wd_context_node.
DATA lo_el_tag_visible TYPE REF TO if_wd_context_element.
DATA ls_tag_visible TYPE wd_this->element_tag_visible.
DATA lv_btn_save TYPE wd_this->element_tag_visible-btn_save.
DATA lo_nd_tag_checked TYPE REF TO if_wd_context_node.
DATA lo_el_tag_checked TYPE REF TO if_wd_context_element.
* DATA ls_tag_checked TYPE wd_this->element_tag_checked.
* DATA lv_save_with_wf TYPE wd_this->element_tag_checked-save_with_wf.
* Types
* TYPES:
* Constants
CONSTANTS :
c_subtype_b2b TYPE bbp_partner_subtype VALUE 'B2B',
c_we TYPE bbp_pds_partner-partner_fct VALUE '00000027',
c_requestor TYPE bbp_pds_partner-partner_fct VALUE '00000016',
c_receipient TYPE bbp_pds_partner-partner_fct VALUE '00000020',
c_location TYPE bbp_pds_partner-partner_fct VALUE '00000075'.
* Variablen
DATA:
lv_error TYPE boolean,
lv_filename TYPE string,
lv_message TYPE string,
lv_acc_cat TYPE bbp_acc_cat,
ln_h0(6) TYPE n,
li_save TYPE xfeld,
li_guid TYPE i,
li_park TYPE xfeld.
* Tabellen
DATA:
lt_function_tab TYPE bbpt_partner_fct_tab,
lt_messages TYPE bbpt_pd_messages,
lt_partner TYPE TABLE OF bbp_pds_partner,
lt_account TYPE TABLE OF bbp_pds_acc,
lt_orgdata TYPE TABLE OF bbp_pds_org,
lt_tax TYPE TABLE OF bbp_pds_tax,
lt_longtext TYPE TABLE OF bbp_pds_longtext,
lt_t77s0 TYPE TABLE OF t77s0.
* Strukturen
DATA:
ls_user_27 TYPE sy-uname,
is_item TYPE bbp_pds_sc_item_d,
ls_item TYPE bbp_pds_sc_item_icu,
ls_header TYPE bbp_pds_sc_header_d,
ls_header_u TYPE bbp_pds_sc_header_u,
ls_header_t TYPE bbp_pds_header,
ls_account TYPE bbp_pds_acc,
ls_partner TYPE bbp_pds_partner,
ls_orgdata TYPE bbp_pds_org,
ls_longtext TYPE bbp_pds_longtext,
ls_tax TYPE bbp_pds_tax,
ls_but000_current TYPE but000,
ls_message LIKE LINE OF lt_messages,
ls_message_text TYPE string,
ls_zbi_ldap TYPE zbi_ldap,
ls_t77s0_key LIKE LINE OF lt_t77s0,
ls_t77s0 LIKE LINE OF lt_t77s0,
ls_function_tab TYPE crmt_partner_fct,
ls_co_code TYPE bukrs,
ls_be_log_system TYPE be_log_system,
ls_logsys_fi TYPE bbp_logsys_fi,
lr_employee TYPE REF TO if_bbp_es_employee.
* Objekte
DATA:
lo_pd_model TYPE REF TO /sapsrm/if_pdo_model_access,
lo_api_controller TYPE REF TO if_wd_controller,
lo_message_manager TYPE REF TO if_wd_message_manager.
* Feld-Symbole
FIELD-SYMBOLS:
* <upload> TYPE wd_this->element_upload_data,
<item_b> TYPE bbp_pds_sc_item_icu,
<item> TYPE bbp_pds_sc_item_icu,
<account> TYPE bbp_pds_acc,
<partner> TYPE bbp_pds_partner,
<longtext> TYPE bbp_pds_longtext,
<orgdata> TYPE bbp_pds_org,
<tax> TYPE bbp_pds_tax.
*------------------------------------------------------------------------------------------------
* Initialisieren
*------------------------------------------------------------------------------------------------
*-----------------------------------------------------------------------------------------------------
* Lesen der Accountdaten aus dem Screen
*-----------------------------------------------------------------------------------------------------
lo_nd_selection = wd_context->get_child_node( name = wd_this->wdctx_selection ).
lo_el_selection = lo_nd_selection->get_element( ).
lo_el_selection->get_attribute( EXPORTING name = `KOSTL` IMPORTING value = lv_kostl ).
lo_el_selection->get_attribute( EXPORTING name = `SAKNR` IMPORTING value = lv_saknr ).
lv_acc_cat = 'CC'.
*-----------------------------------------------------------------------------------------------------
* GUID der einzelnen Positionen in den Strukturen. Wird immer um 1 erhöht.
*-----------------------------------------------------------------------------------------------------
li_guid = 1.
*-----------------------------------------------------------------------------------------------------
* Guid der Bestellung und Instance des SC
*-----------------------------------------------------------------------------------------------------
lv_guid = wd_comp_controller->mo_bom_sc->/sapsrm/if_cll_bo_mapper~get_bo_guid( ).
lo_sc = /sapsrm/cl_pdo_factory_sc_adv=>get_buffered_instance( lv_guid ). " Get SC Instance
*------------------------------------------------------------------------------------------------
* Einen ShoppingCart erstellen
*------------------------------------------------------------------------------------------------
* ------------------------------------------------------------------------------------------------
* Header Informationen
* ------------------------------------------------------------------------------------------------
lo_nd_header = wd_context->get_child_node( name = wd_this->wdctx_header ).
lo_el_header = lo_nd_header->get_element( ).
lo_el_header->get_static_attributes( IMPORTING static_attributes = is_header ).
is_header-guid = lv_guid.
is_header-process_type = 'SHC'.
is_header-purchteam = 'STANDARD'.
is_header-currency = 'EUR'.
* is_header-z_hsk = 'X'. "eventuell aus dem View übernehmen
is_header-z_sc_typ = 3. "Kennzeichen für SC aus ServieManager
TRY.
MOVE-CORRESPONDING is_header TO ls_header_u.
CALL METHOD lo_sc->/sapsrm/if_pdo_bo_sc~update_header
EXPORTING
is_header = ls_header_u
CHANGING
co_message_handler = lv_co_message_handler.
CATCH /sapsrm/cx_pdo_wrong_mode .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_no_authorizatio .
lv_error = abap_true.
ENDTRY.
* ------------------------------------------------------------------------------------------------
* Items mit der Parent GUID füllen
* ------------------------------------------------------------------------------------------------
IF lv_error = abap_true.
lo_nd_item = wd_context->get_child_node( name = wd_this->wdctx_item ).
lo_nd_item->get_static_attributes_table( IMPORTING table = lt_item ).
LOOP AT lt_item ASSIGNING <item_b>. "Basisinformationen der Daten aus dem SM
li_guid = li_guid + 1.
APPEND INITIAL LINE TO it_item ASSIGNING <item>.
<item>-parent = is_header-guid.
<item>-guid = li_guid.
<item>-number_int = sy-tabix.
<item>-currency = 'EUR'.
<item>-product_type = '01'.
<item>-be_doc_type = 'EC'.
<item>-z_userad = <item_b>-z_userad.
<item>-z_h0_nummer_alt = <item_b>-z_h0_nummer_alt.
ln_h0 = sy-tabix.
CONCATENATE 'Z' ln_h0 INTO <item>-z_h0_nummer.
<item>-quantity = 1. "<item_b>-quantity.
<item>-partner_prod = <item_b>-partner_prod.
<item>-be_po_price = '1'.
<item>-be_co_code = ls_co_code.
<item>-be_log_system = ls_be_log_system. "'E71CLNT701'.
<item>-logsys_fi = ls_logsys_fi. "'E31CLNT390'.
* ----------------------------------------------------------------------------------------------------
* MDM Catalog Daten
* ----------------------------------------------------------------------------------------------------
<item>-catalogid = 'SRM_MDM_IT'.
<item>-description = 'Test Henkel'.
<item>-price_unit = 1.
<item>-subtype = 'EP'.
<item>-price = '55.00'.
<item>-gross_price = '55.00'.
<item>-be_pur_group = 'E01'.
<item>-be_pur_org = '1104'.
* <item>-be_po_price = '1'.
<item>-be_plant = '4000'.
<item>-z_tax_code_cat = '19'.
<item>-unit = 'ST'.
<item>-leadtime = '14'.
<item>-del_datcat = '1'.
<item>-deliv_date = '20130424'.
<item>-category_id = '19010105'.
<item>-category = '5135F816C8CB0C70E1008000AC1428A6'.
* Notebook 5135F818C8CB0C70E1008000AC1428A6 19010107
* Personalcomputer 5135F816C8CB0C70E1008000AC1428A6 19010105
<item>-z_hersteller = 'Microtec'.
<item>-z_modell = '0000002443'.
<item>-z_price_ibb = '415'.
<item>-z_tax_code_cat = 'V0'.
* *********************************************************************
* Hinzufügen zum SC-Buffer der ITEMS
* *********************************************************************
TRY.
lo_sc->/sapsrm/if_pdo_bo_sc~add_item( EXPORTING iv_uname = sy-uname is_item = <item> ).
CATCH /sapsrm/cx_pdo_no_authorizatio .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_abort .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_incons_user .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_curr_error .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_cat_not_allowed .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_prd_not_found .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_prd_not_unique .
lv_error = abap_true.
ENDTRY.
IF lv_error = abap_true.
EXIT.
ENDIF.
* ------------------------------------------------------------------------------------------------
* Account
* ------------------------------------------------------------------------------------------------
APPEND INITIAL LINE TO lt_account ASSIGNING <account>.
<account>-p_guid = <item>-guid.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = <account>-guid.
<account>-g_l_acct = lv_saknr.
<account>-cost_ctr = lv_kostl.
<account>-acc_cat = lv_acc_cat.
<account>-distr_perc = 100.
SHIFT <account>-g_l_acct RIGHT DELETING TRAILING space. "mit führenden Nullen auffüllen
OVERLAY <account>-g_l_acct WITH '0000000000'.
SHIFT <account>-cost_ctr RIGHT DELETING TRAILING space. "mit führenden Nullen auffüllen
OVERLAY <account>-cost_ctr WITH '0000000000'.
<account>-acc_no = 1.
* ------------------------------------------------------------------------------------------------
* Longtext (Lieferantentext )
* ------------------------------------------------------------------------------------------------
APPEND INITIAL LINE TO lt_longtext ASSIGNING <longtext>.
<longtext>-guid = <item>-guid.
<longtext>-tdid = 'ITXT'.
<longtext>-tdspras = 'D'.
<longtext>-counter = sy-tabix.
<longtext>-tdline = 'Personalcomputer inkl. Windows 7 Professional'.
TRY.
CALL METHOD lo_sc->/sapsrm/if_pdo_do_longtext~add_longtext
EXPORTING
iv_p_guid = <longtext>-guid
iv_tdid = <longtext>-tdid
iv_tdspras = <longtext>-tdspras
iv_tdformat = 'X'
iv_text_preview = 'Personalcomputer inkl. Windows 7 Professional'
CHANGING
co_message_handler = lv_co_message_handler.
CATCH /sapsrm/cx_pdo_abort .
lv_error = abap_true.
EXIT.
ENDTRY.
ENDLOOP.
ENDIF.
**********************************************************************
* Submit Update der Account Informationen
**********************************************************************
IF lv_error = abap_false.
TRY.
CALL METHOD lo_sc->/sapsrm/if_pdo_do_acct_assgmnt~add_account_assignment
EXPORTING
it_account = lt_account
CHANGING
co_message_handler = lv_co_message_handler.
CATCH /sapsrm/cx_pdo_abort .
lv_error = abap_true.
ENDTRY.
ENDIF.
**********************************************************************
* Submit Update
**********************************************************************
IF lv_error = abap_false.
TRY.
lo_sc->/sapsrm/if_pdo_base~submit_update( CHANGING co_message_handler = lv_co_message_handler ).
CATCH /sapsrm/cx_pdo_wrong_mode .
lv_error = abap_true.
CATCH /sapsrm/cx_pdo_abort .
lv_error = abap_true.
ENDTRY.
ENDIF.
**********************************************************************
* Errorhandling
**********************************************************************
IF lv_error = abap_true.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
CALL METHOD lo_message_manager->report_message
EXPORTING
message_text = 'Achtung! Fehler bei der Erstellung der Bestellung. Henkel anrufen 2968'.
EXIT.
ELSE.
lo_pd_model = /sapsrm/cl_pdo_model_factory=>get_instance( ).
lo_pd_model->get_detail( EXPORTING iv_guid = lv_guid
IMPORTING es_header = ls_header_t ).
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
CALL METHOD lo_message_manager->report_success
EXPORTING
message_text = 'Bestellung erfolgreich übertragen'.
CONCATENATE 'Einkaufswagen: ' ls_header_t-object_id INTO lv_message.
CALL METHOD lo_message_manager->report_success
EXPORTING
message_text = lv_message.
ENDIF.
ENDMETHOD.
Back in the calling component i refresh the buffer...
method ONACTIONIMPORT_ABT_OK .
DATA lo_fpm type ref to if_fpm.
wd_comp_controller->MO_BOM_SC->/SAPSRM/IF_CLL_MAPPER~REFRESH( ).
lo_fpm = cl_fpm_factory=>get_instance( ).
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.