Thursday, August 27, 2015

DO_PREPARE_OUTPUT - CRM Web UI example


Component/View:   BT125H_TASK/TaskDetails
Logic:

typed_context will contain all context nodes in view.


    DATAlr_btstatus        TYPE REF TO cl_crm_bol_entity,
          lr_btadminh        TYPE REF TO cl_crm_bol_entity.
    DATAlv_process_type    TYPE CRMT_PROCESS_TYPE_DB.



    TRY.
    lr_btadminh ?= me->typed_context->btadminh->collection_wrapper->get_current).
    lr_btadminh->get_property_as_value(
                                    EXPORTING iv_attr_name 'PROCESS_TYPE'
                                    IMPORTING ev_result    lv_process_type ).

    lr_btstatus ?= me->typed_context->btstatus->collection_wrapper->get_current).

*   For Attachment tasks (ZATC), set status to 'Completed'
    IF lv_process_type 'ZATC'.
      lr_btstatus->set_property(
        EXPORTING
          iv_attr_name =   'ACT_STATUS'
          iv_value     =    'E0003'
      ).

    ENDIF.
      CATCH cx_root.
   ENDTRY.

CRM WebUI Get related entities and Parent entities



If you need to get entities related (child entities), use GET_RELATED_ENTITY, GET_RELATED_ENTITIES methods

Using GET_RELATED_ENTITY:

    lr_erpadminh ?=   me->typed_context->erpadminh->collection_wrapper->get_current).
    CHECK  lr_erpadminh IS BOUND.
    lr_erpadminh->get_property_as_value(  EXPORTING   iv_attr_name =   'VBELN'
                                          IMPORTING   ev_result    =   lv_vbeln .

*    CHECK  lv_vbeln IS NOT INITIAL.
    TRY.
        CALL METHOD lr_erpadminh->get_related_entity
          EXPORTING
            iv_relation_name 'ERPHeaderCondSet'
*           iv_mode          = normal
          RECEIVING
            rv_result        lr_erpcondh.
      CATCH cx_crm_genil_model_error .
    ENDTRY.
    IF lr_erpcondh IS BOUND.
      TRY.
          CALL METHOD lr_erpcondh->get_related_entities
            EXPORTING
              iv_relation_name 'ERPCondHAll'
*             iv_child_name    =
*             iv_mode          = NORMAL
*             iv_owned_only    = ABAP_FALSE
            RECEIVING
              rv_result        lr_condcol.
        CATCH cx_crm_genil_model_error .
      ENDTRY.


      CLEAR  lr_iterator ls_condtype.
      lr_iterator   lr_condcol->get_iterator).

Full code link: http://sapist.blogspot.co.uk/2015/08/crm-web-ui-getrelatedentity.html


If you need parent entities, then use GET_PARENT method

Using GET_PARENT method:

    if iterator is bound.
      current iterator->get_current).
    else.
      current collection_wrapper->get_current).
    endif.

    lr_current ?= current.

    TRY.
      lr_bt_statush ?= lr_current->get_parent).

      CATCH cx_crm_genil_model_error .
    ENDTRY.

    TRY.
      lr_bt_adminh ?= lr_bt_statush->get_parent).

      CATCH cx_crm_genil_model_error .
    ENDTRY.

    TRY.

    lr_bt_adminh->get_property_as_value(  EXPORTING IV_ATTR_NAME 'PROCESS_TYPE'
                                            IMPORTING EV_RESULT lv_process  ).

      CATCH cx_root.
    ENDTRY.

Full code link: http://sapist.blogspot.co.uk/2015/08/crm-web-ui-getparent-method.html

CRM Web UI GET_PARENT method



If you need parent entities, then use GET_PARENT method

Using GET_PARENT method:

    DATAcurrent TYPE REF TO if_bol_bo_property_access.
    DATAdref    TYPE REF TO data.


    DATAlr_current    TYPE REF TO cl_crm_bol_entity,
          lr_bt_statush TYPE REF TO cl_crm_bol_entity,
          lr_bt_adminh  TYPE REF TO cl_crm_bol_entity.
    DATAlv_process TYPE CRMT_PROCESS_TYPE_DB.


    if iterator is bound.
      current iterator->get_current).
    else.
      current collection_wrapper->get_current).
    endif.

    lr_current ?= current.

    TRY.
      lr_bt_statush ?= lr_current->get_parent).

      CATCH cx_crm_genil_model_error .
    ENDTRY.

    TRY.
      lr_bt_adminh ?= lr_bt_statush->get_parent).

      CATCH cx_crm_genil_model_error .
    ENDTRY.

    TRY.

    lr_bt_adminh->get_property_as_value(  EXPORTING IV_ATTR_NAME 'PROCESS_TYPE'
                                            IMPORTING EV_RESULT lv_process  ).

      CATCH cx_root.
    ENDTRY.

CRM Web UI GET_RELATED_ENTITY, GET_RELATED_ENTITIES methods




If you need to get entities related (child entities), use GET_RELATED_ENTITY, GET_RELATED_ENTITIES methods

Using GET_RELATED_ENTITY, GET_RELATED_ENTITIES :


    DATA  :  lr_erpadminh     TYPE REF TO cl_crm_bol_entity,
             lr_erpcondh     TYPE REF TO cl_crm_bol_entity,
             lr_condh     TYPE REF TO if_bol_bo_property_access,
             lr_condcol TYPE REF TO if_bol_entity_col,
             lr_iterator TYPE REF TO if_bol_entity_col_iterator,
             lr_rate     TYPE REF TO if_bol_bo_property_access,
             lv_vbeln TYPE string ,
             lv_cond_value TYPE kwert,
             lv_curr TYPE waerk.

    DATA  :  lv_changeable TYPE boolean.

    TYPESBEGIN OF ty_condtype,
              znet_gp TYPE kwert,
              znet_gp_p TYPE kbetr,
              zgp TYPE kwert,
              zgp_p TYPE kbetr,
              zfrc TYPE kwert,
              zd01 TYPE kwert,
              znet_gp_cur TYPE waerk,
              znet_gp_p_cur TYPE waerk,
              zgp_cur TYPE waerk,
              zgp_p_cur TYPE waerk,
              zfrc_cur TYPE waerk,
              zd01_cur TYPE waerk,
              zdel_route TYPE route,
              zccs TYPE kschl,
              zoppt_desp TYPE descr_40,
              zsam_descp TYPE descr_40,
          END OF ty_condtype.

    DATA ls_condtype TYPE ty_condtype.



    lr_erpadminh ?=   me->typed_context->erpadminh->collection_wrapper->get_current).
    CHECK  lr_erpadminh IS BOUND.
    lr_erpadminh->get_property_as_value(  EXPORTING   iv_attr_name =   'VBELN'
                                          IMPORTING   ev_result    =   lv_vbeln .

*    CHECK  lv_vbeln IS NOT INITIAL.
    TRY.
        CALL METHOD lr_erpadminh->get_related_entity
          EXPORTING
            iv_relation_name 'ERPHeaderCondSet'
*           iv_mode          = normal
          RECEIVING
            rv_result        lr_erpcondh.
      CATCH cx_crm_genil_model_error .
    ENDTRY.
    IF lr_erpcondh IS BOUND.
      TRY.
          CALL METHOD lr_erpcondh->get_related_entities
            EXPORTING
              iv_relation_name 'ERPCondHAll'
*             iv_child_name    =
*             iv_mode          = NORMAL
*             iv_owned_only    = ABAP_FALSE
            RECEIVING
              rv_result        lr_condcol.
        CATCH cx_crm_genil_model_error .
      ENDTRY.


      CLEAR  lr_iterator ls_condtype.
      lr_iterator   lr_condcol->get_iterator).

      IF lr_iterator IS BOUND.
*      Reading the Net gross profit values ..
        CLEAR lr_rate.
        CALL METHOD lr_iterator->find_by_property
          EXPORTING
            iv_attr_name 'KSCHL_T'
            iv_value     text-004  "'Net Gross Profit'(004)
          RECEIVING
            rv_result    lr_rate.

        IF lr_rate IS BOUND.
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'KWERT'
                                          IMPORTING ev_result  lv_cond_value ).
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'WAERK'
                                                    IMPORTING ev_result  lv_curr ).

          ls_condtype-znet_gp lv_cond_value.
          ls_condtype-znet_gp_cur lv_curr.
        ENDIF.

*      Reading the Net Margin%  values ..
        CLEAR lr_rate ,lv_curr,  lv_cond_value.
        CALL METHOD lr_iterator->find_by_property
          EXPORTING
            iv_attr_name 'KSCHL_T'
            iv_value     text-005   "'Net Margin %'(005)
          RECEIVING
            rv_result    lr_rate.

        IF lr_rate IS BOUND.
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'KBETR'
                                          IMPORTING ev_result  lv_cond_value ).
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'WAERK'
                                                    IMPORTING ev_result  lv_curr ).
          ls_condtype-znet_gp_p lv_cond_value.
          ls_condtype-znet_gp_p_cur lv_curr.
        ENDIF.
*      Reading the Gross Profit values ..
        CLEAR lr_rate ,lv_curr,  lv_cond_value.
        CALL METHOD lr_iterator->find_by_property
          EXPORTING
            iv_attr_name 'KSCHL_T'
            iv_value     text-003 " 'Gross Profit'
          RECEIVING
            rv_result    lr_rate.

        IF lr_rate IS BOUND.
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'KWERT'
                                          IMPORTING ev_result  lv_cond_value ).
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'WAERK'
                                                    IMPORTING ev_result  lv_curr ).
          ls_condtype-zgp lv_cond_value.
          ls_condtype-zgp_cur lv_curr.
        ENDIF.
*      Reading the Margin% Values ..
        CLEAR lr_rate ,lv_curr,  lv_cond_value..
        CALL METHOD lr_iterator->find_by_property
          EXPORTING
            iv_attr_name 'KSCHL_T'
            iv_value     text-001   "'Margin %'(001)
          RECEIVING
            rv_result    lr_rate.

        IF lr_rate IS BOUND.
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'KBETR'
                                          IMPORTING ev_result  lv_cond_value ).
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'WAERK'
                                                    IMPORTING ev_result  lv_curr ).
          ls_condtype-zgp_p lv_cond_value.
          ls_condtype-zgp_p_cur lv_curr.
        ENDIF.

*       Reading the ZFRC Values ..
        CLEAR lr_rate ,lv_curr,  lv_cond_value..
        CALL METHOD lr_iterator->find_by_property
          EXPORTING
            iv_attr_name 'KSCHL'
            iv_value     text-002    "'ZFRC'
          RECEIVING
            rv_result    lr_rate.

        IF lr_rate IS BOUND.
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'KWERT'
                                          IMPORTING ev_result  lv_cond_value ).
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'WAERK'
                                                    IMPORTING ev_result  lv_curr ).
          ls_condtype-zfrc lv_cond_value.
          ls_condtype-zfrc_cur lv_curr.
        ENDIF.


*       Reading the ZD01 Values ..
        CLEAR lr_rate ,lv_curr,  lv_cond_value.
        CALL METHOD lr_iterator->find_by_property
          EXPORTING
            iv_attr_name 'KSCHL'
            iv_value     'ZD01'
          RECEIVING
            rv_result    lr_rate.

        IF lr_rate IS BOUND.
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'KWERT'
                                          IMPORTING ev_result  lv_cond_value ).
          lr_rate->get_property_as_valueEXPORTING iv_attr_name 'WAERK'
                                                    IMPORTING ev_result  lv_curr ).
          ls_condtype-zd01 lv_cond_value.
          ls_condtype-zd01_cur lv_curr.
        ENDIF.

        lr_condh ?=   me->typed_context->condtype->collection_wrapper->get_current).
        IF lr_condh IS BOUND.

          CALL METHOD lr_condh->set_properties
            EXPORTING
              is_attributes ls_condtype.
        ENDIF.
      ENDIF.
    ENDIF.

Friday, August 21, 2015

Packing status in Delivery header


Packing status in Delivery header will be changed to 'C' (Completed) though there are some items with out packing.

This is standard behaviour if the item category is set to (in 0VLP) 'Can be packed' - As it is not necessary for all items to be Packed.

There is a different setting in 0VLP called 'must be packed' - you can use this if you want header to be Completed only if all items are must packed.

SAP note (KBA) - 1508233 

Wednesday, August 12, 2015

SAP PI architecture

 
 

Block for Accounting - Posting block

SPRO config:
Billing Document type -> Posting block
 
 
 

Credit Management: Setup credit check for documents

VOV8 -> Check Credit limit
 
SPRO-> Sales and Distribution -> Basic Functions -> Credit Management ->
 

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Tuesday, August 11, 2015

CRM - Set valid 'Titles' for Business partner types



V_TSAD3 - view - for valid Titles for different business partner types (Organization, Person and Group)

F110 BSEG-SGTXT (text) population


http://scn.sap.com/thread/1162018

Make use of BTE 00001120. You can find documentation
for the usage of this event in transaction BERP, enter process
interface 00001120   > execute   > Keep cursor on the event 00001120 and
then click documentation.
 
extra info:
 
In order to have the payment program transfer the text from the FI
document (BSEG-SGTXT) to the field REGUP-SGTXT you have to place a '*'
in the first column of BSEG-SGTXT when posting the invoice. Example:
 
BSEG-SGTXT = Test
 
should instead look like
 
BSEG-SGTXT = *Test
 
Also, the content of BSEG-SGTXT can only be transfered if it's been
entered manually. In case you have a non standard program that fills
out the field BSEG-SGTXT the payment program will not be able to copy
the text into REGUP-SGTXT for technical reasons.
 
Please check attached notes 3967 and 3652 for further clarification.

Debugging Bdoc - 'Fill in all required entry' error case


SAP note:  1541354     (for issue saying 'Fill in all required entries')


It is possible to debug the upload as follows, in order to identify the required field:                              
  1. Display the BDOC in SMW01
  2. Enter /h in the transaction code field
  3. Press the 'retry to process message' button.
  4. In the debugger - select the Settings button and 'In background task  do not process' (Classical debugger) or for New Debugger, select from Menu: Settings and select "Change Profile Debugger/Settings" then mark flag for "TRFC (In Background Task): Block Sending" and click on icon "Enter".
  5. Enter F8
  6. Create a new session for the outbound queue (/osmq1) there will be an entry R3AUBUPA*** or CSA_BUPA**
  7. Double-Click on this queue entry twice and choose Debug for the CRM_UPLOAD_TRIGGER
  8. In the debugger, set a breakpoint at statement 'CALL TRANSACTION' and then press F8.
  9. At this statement double-click on the statement CALL_TRANSACTION and change the variable CALL_TRANSACTION_MODE from N to A, press the 'change field content' button and then press F8
  10. Now you will be in the R/3 System and you can see the batch input screen for this customer and you will then be prompted for the missing field in the BDOC.
When the field has been identified, please maintain this field in CRM.
Remark: In order to enter into debugging mode, you should ensure that the USER to connect to the R/3 system via RFC (txn SM59, Logon and Security tab), is set in your R/3 system as Dialog mode (txn SU01). Also RFC user must have debugging authorization.

Friday, August 7, 2015

CHBK - Set to complete status manually - if not needed to go for CHBC


WLF2V tcode -> From Menu (Remuneration Settlement) -> Select 'Complete'.

Completed documents will not appear in WLFCOL tcode - > So, no CHBCs can be created on them