Apr 28, 2016

IDOC T-Codes

Here is the list of important ALE IDOC transaction codes and its purposes for a quick reference.

SALE – This transaction code is used for access IMG ALE Configuration root
WE05 – IDoc overview
WE07 – IDoc statistics
WE20 – This transaction code is used for manually maintain partner profiles
WE21 – This transaction code is used for Ports in Idoc processing
WE47 – This transaction code is used for edit IDOC status values. (Real path: SALE -> Set-Up System Monitoring -> IDoc Status Display -> Edit IDoc Status Values)
WE60 – This transaction code is used for create IDoc documentation (IDOC header file)
SM59 – This transaction code is used for Create RFC Destinations
SM58 – Schedule RFC Failures
BD21 – Create IDocs from change pointers
BD50 – This transaction code is used for Activate Change Pointer for Message Type
BD52 – This transaction code is used for Activate change pointer per change.doc object
BD53 – This transaction code is used for Reduction of Message Types
BD55 – This transaction code is used for Defining settings for IDoc conversion
BD56 – This transaction code is used for Maintain IDOC Segment Filters
BD59 – This transaction code is used for Allocation object type -> IDOC type
BD61 – This transaction code is used for Activate Change Pointers – Globally
BD62 – This transaction code is used for Define rules
BD64 – This transaction code is used for Maintain customer distribution model
BD71 – This transaction code is used for Distribute customer distribution model
BD79 – This transaction code is used for Maintain rules
BD82 – This transaction code is used for Generate Partner Profiles
BD87 – This transaction code is used for Status Monitor for ALE Messages (Real access path is    Tools -> IDoc Interface/ALE -> Administration ->Monitoring -> IDoc Display ->Status Monitor )
BD88 – Outbound IDoc reprocessing
BDM2 – IDoc Trace
BDM5 – This transaction code is used for Consistency check
BDM7 – IDoc Audit Analysis
WEDI – This transaction code is used for ALE IDoc Administration
SARA – This transaction code is used for IDoc archive administration
BALE – ALE Distribution Administration

Apr 20, 2016

Call a Transaction in New Session Window

Call a transaction in New Session from ALV Hotspot.

We can use FM  ABAP4_CALL_TRANSACTION for this. But from SCN, I found an excellent way to do so.

Create a Remote enable function module:

ZFM_CALL_TCODE_IN_NEW_WINDOW :
-----------------------------------------------------
function zfm_call_tcode_in_new_window.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(TCODE) TYPE  SY-TCODE
*"     VALUE(VBELN) TYPE  VBELN
*"     VALUE(PARAID) TYPE  MEMORYID
*"----------------------------------------------------------------------

set parameter id paraid field vbeln.
  call transaction tcode and skip first screen.

endfunction.

---------------------------------------------------------------
Call the FM from the program:

You have to use the following code segment  in program to call that Function Module ,
-------------------------------------------------
      lv_tcode 'VA43'.              "Tcode to Call
      lv_vbeln gs_out-vbeln.
      lv_paraid 'KTN'.
      call function 'ZFM_CALL_TCODE_IN_NEW_WINDOW' starting new task 'TEST'
        destination 'NONE'
        exporting
          tcode         lv_tcode
          vbeln         lv_vbeln
          paraid        lv_paraid
                .

------------------------------------------------

*Ref: https://wiki.scn.sap.com/wiki/display/Snippets/How+to+Call+a+Transaction+in+New+Session+Window

Apr 18, 2016

ABAP Performance and Tuning

What tools can be used to help with performance tuning?

ST05 is the performance trace. It contain the SQL Trace plus RFC, enqueue and buffer trace. Mainly the SQL trace is is used to measure the performance of the select statements of the program.
SE30 is the Runtime Analysis transaction and can be used to measure the application performance. 
SAT transaction is the replacement of the pretty outdated SE30. Provides same functionality as SE30 plus some additional features.
ST12 transaction (part of ST-A/PI software component) is a combination of ST05 and SAT. Very powerful performance analysis tool used primarily by SAP Support.
One of the best tools for static performance analyzing is Code Inspector (SCI). There are many options for finding common mistakes and possible performance bottlenecks.

Mar 22, 2016

Useful Standard SAP Reports


Task
Report
Function Module/BAPI
Report for Converting the IDoc Status 
RC1_IDOC_SET_STATUS

RFC - Connection Test
RSRFCPIN  
CAT_CHECK_RFC_DESTINATION

RSRFCCHK
RFC_CHECK_DESTINATION

RSRFCPIN_NEW
RFC_CHECK_DESTINATION_ID

RSRFCTES
SCWB_RFC_CHECK_DESTINATION
Reprocess IDOC status 51
RBDMANIN


RBDMANI2

Reprocess IDOC status 64
RBDAPP01

Reprocess IDOC status 30
RSEOUT00

Reprocess IDOC status 32 & 69-Edited
RBDAGAIE

Reprocess IDOC status 26
RBDSYNER

Jan 15, 2016

ABAP: Send Email with attached Internal Table XLS file

Function module that will take any internal table as input,  convert in to XLS format
and send out emails with the attachment.

 Add the appropriate import parameters.

Add appropriate table parameters.









Source Code
====================================================
function zinttab_excl_email.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(SENDER) TYPE  AD_SMTPADR
*"     REFERENCE(SUBJECT) TYPE  SO_OBJ_DES
*"  TABLES
*"      RECEPIENTS TYPE  BCSY_SMTPA
*"      RETURN TYPE  TABLE_OF_STRINGS OPTIONAL
*"      DATA_TO_SEND
*"      EMAIL_BODY TYPE  BCSY_TEXT
*"----------------------------------------------------------------------
*Function module that will take any internal table as input,  convert in to XLS format
*and send out emails with the attachment. :SATYABRATA SAHOO
*"----------------------------------------------------------------------
  if recepients[] is initial.
    return.
  endif.

  datalo_send_request   type ref to cl_bcs,
        lo_document       type ref to cl_document_bcs,
        lo_sender_id      type ref to if_sender_bcs,
        lo_recipient      type ref to if_recipient_bcs.
  datalo_bcs_exception  type ref to cx_bcs.
  datalv_bcs_message    type string,
        lv_send_to_all    type os_boolean,
        lv_fields(10).

  field-symbols< fs_recipient > type ad_smtpadr.

*******************************************************************************
* build the file content

  datalo_struct_type  type ref to cl_abap_structdescr,
        lo_element_type type ref to cl_abap_elemdescr.
  datalt_components   type cl_abap_structdescr=>component_table,
        ls_field        type dfies.
  field-symbols type abap_componentdescr.

  datalt_binary_text  type solix_tab,
        lv_text         type string,
        lv_size         type so_obj_len.

* build the header data
  lo_struct_type ?= cl_abap_typedescr=>describe_by_datadata_to_send ).
  lt_components   lo_struct_type->get_components).
  loop at lt_components assigning .
    if sy-tabix gt 1.
      concatenate lv_text cl_bcs_convert=>gc_tab into lv_text.
    endif.
    lo_element_type ?= -type.
    ls_field         lo_element_type->get_ddic_field).
    concatenate lv_text ls_field-scrtext_l into lv_text.
  endloop.
  concatenate lv_text cl_bcs_convert=>gc_crlf into lv_text.

* build the structure of the body
  field-symbols   type any,
                  type any.
  loop at data_to_send assigning .
    loop at lt_components assigning .
      if sy-tabix gt 1.
        concatenate lv_text cl_bcs_convert=>gc_tab into lv_text.
      endif.
      assign component -name of structure  to .
      lv_fields .
      condense lv_fields.
*      concatenate lv_text  into lv_text.
      concatenate lv_text lv_fields into lv_text.
    endloop.
    concatenate lv_text cl_bcs_convert=>gc_crlf into lv_text.
  endloop.

  try .
      cl_bcs_convert=>string_to_solix(
        exporting
          iv_string   lv_text
          iv_codepage '4103' "suitable for MS Excel, leave empty"
          iv_add_bom  abap_true
        importing
          et_solix    lt_binary_text
          ev_size     lv_size ).
    catch cx_bcs into lo_bcs_exception.
      lv_bcs_message lo_bcs_exception->get_text).
      append lv_bcs_message to return.
      exit.
  endtry.

*******************************************************************************
* send an email
  try .
      clearlo_send_requestlo_documentlo_sender_id.
      lo_send_request cl_bcs=>create_persistent).
      lo_document     cl_document_bcs=>create_document(
                                  i_type    'RAW'
                                  i_text    email_body[]
                                  i_subject subject ).

      if not data_to_send[] is initial.
        lo_document->add_attachment(
                   i_attachment_type    'XLS'
                   i_attachment_subject subject
                   i_attachment_size    lv_size
                   i_att_content_hex    lt_binary_text ).
      endif.

      lo_send_request->set_documentlo_document ).


      lo_sender_id    cl_cam_address_bcs=>create_internet_addresssender ).

      lo_send_request->set_senderlo_sender_id ).
*     add recipients
      loop at recepients assigning .
        clear lo_recipient.
        lo_recipient cl_cam_address_bcs=>create_internet_address ).
*       add recipient with its respective attributes to send request
        lo_send_request->add_recipienti_recipient lo_recipient
                                        i_express   abap_true ).
      endloop.

      lo_send_request->set_status_attributesi_requested_status 'E'
                                              i_status_mail      'E' ).
      lo_send_request->set_send_immediatelyabap_true ).
      lv_send_to_all lo_send_request->sendi_with_error_screen abap_true ).

      if lv_send_to_all eq abap_true.
        datals_return like line of return.
        ls_return text-001"Success
        append ls_return to return.
      endif.
      commit work.
    catch cx_bcs into lo_bcs_exception.
      lv_bcs_message lo_bcs_exception->get_text).
      append lv_bcs_message to return.
      exit.
  endtry.
endfunction.

============================================

Ref-http://techsplice.com/

How to change Transport request from Released to Modifiable

Step 1: Go to SE38 – Execute Program RDDIT076.  Step 2: Give your released requests number and execute again. Step 3: After executing, yo...