Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts

Tuesday, December 16, 2025

Debug Program externally or remotely

 

To debug a program run remotely,  the user need to type below in command, to give access to developer to debug externally (remotely).  Developer need to put an external breakpoint with user's userid.

/HEXT user = <developer_username_who_will_debug>


Note:  Developer FIRST need to set the external breakpoint with user's userid - before user doing above in command line. (Its like mutual consent)


Friday, December 20, 2019

Custom PF-status - copy from program RSSYSTDB

If you wan to add buttons to selection screen beside 'Execute' - then its better to take copy of pf-status from program RSSYSTDB via SE41

Thursday, May 31, 2018

Thursday, November 9, 2017

CRM ABAP load Core with component set


Code to set Core to a particular component.  This works if u r writing a stand-alone program or function.  If this is not written, then you may not get relations loaded and get issues.  You need to put right component set name (in place of 'IUICALL') in below code

DATA:  lr_core            TYPE REF TO cl_crm_bol_core.


  lr_core = cl_crm_bol_core=>get_instance( ).

  CHECK lr_core IS BOUND.

  TRY.
      lr_core->load_component_set( iv_component_set_name = 'IUICALL' ).
    CATCH cx_crm_genil_general_error .
  ENDTRY.

Tuesday, October 17, 2017

Add entries to empty table via Debugging

Set Breakpoint in FM:- RS_TABLE_LIST_CREATE , line 274 .
Goto se16N- Enter the name of custom table . Set in Debug mode, Hit ‘Create entries:-

Now in debug mode the above FM will be called. Set dd021-mainflag = ‘X’ in debug mode.
Note:-dd02l-mainflag is called twice, thus you may have to set the value twice.



Wednesday, August 2, 2017

FM to add object to Transport

FM to add object to Transport from ABAP program

FM:   TR_APPEND_TO_COMM_OBJS_KEYS


Thursday, March 2, 2017

Hide your code from other developers


SAPLS38E
FM - LOCK_SOURCE
FM - EDITOR_USER_EXIT  - In this there is a custom user exit ZXSEUU08

In ZXSEUU08, you can put your conditions and RAISE CANCELLED exception which will then return 'Program cancelled' message to other developers who wants to access your part of code (FM, Subroutine etc..)

Wednesday, February 15, 2017

Authorization check Function module


FM that does Authorization check

Function module:  AUTH_CHECK_TCODE


Friday, August 26, 2016

Wednesday, June 15, 2016

Add custom fields to Material Master - MM01

How to add custom fields to Material Master - MM01/2  - and in MARA (Append structure)


http://scn.sap.com/docs/DOC-47544
http://scn.sap.com/community/abap/blog/2015/03/06/additional-fields-on-the-material-master

Monday, April 25, 2016

SLG1 Logging program


First go to SLG0 tcode, and setup Object 'ZCMS'

then put below code in your program 

   DATA: ls_log            TYPE BAL_S_LOG.  " CMS Logging
    DATA: ls_msg            TYPE BAL_S_MSG.
    DATA: ls_LOG_HANDLE     TYPE  BALLOGHNDL.
    DATA: lt_LOG_HANDLE     TYPE BAL_T_LOGH.


    CLEAR : ls_log.
    ls_log-object = 'ZCMS'.
    ls_log-aluser = sy-uname.
    ls_log-alprog = sy-repid.

    CALL FUNCTION 'BAL_LOG_CREATE'
      EXPORTING
        I_S_LOG                 = ls_log
      IMPORTING
        E_LOG_HANDLE            = ls_log_handle
      EXCEPTIONS
        LOG_HEADER_INCONSISTENT = 1
        OTHERS                  = 2.



        CLEAR: ls_msg.
        ls_msg-msgty = 'S'.
        ls_msg-msgid = 'ZCRM'.
        ls_msg-msgno = '000'.
        ls_msg-msgv1 = 'Process Type'.
        ls_msg-msgv2 = ''.
        ls_msg-msgv3 = lv_process_type.
        ls_msg-probclass = 2.


        CALL FUNCTION 'BAL_LOG_MSG_ADD'
          EXPORTING
            I_LOG_HANDLE     = ls_log_handle
            I_S_MSG          = ls_msg
          EXCEPTIONS
            LOG_NOT_FOUND    = 1
            MSG_INCONSISTENT = 2
            LOG_IS_FULL      = 3
            OTHERS           = 4.



    INSERT ls_log_handle INTO TABLE lt_log_handle.
    CALL FUNCTION 'BAL_DB_SAVE'
      EXPORTING
        I_CLIENT         = SY-MANDT
        I_IN_UPDATE_TASK = 'X'
        I_SAVE_ALL       = 'X'
        I_T_LOG_HANDLE   = lt_log_handle
      EXCEPTIONS
        LOG_NOT_FOUND    = 1
        SAVE_NOT_ALLOWED = 2
        NUMBERING_ERROR  = 3
        OTHERS           = 4.
    IF SY-SUBRC EQ 0.
      REFRESH: lt_log_handle.
    ENDIF.

Wednesday, April 13, 2016

Short Dumps - understanding values



Your 3 rows are, top to bottom: Human readable*, Hexidecimal high value, Hexidecimal low value. 

So for character values you can already read them. 

* Now for the tricky part. Numeric values are often 'packed' so they use less memory. Each number that is printed has hex values 30 - 39 (ASCII, for EBCDIC F0 - F9). A packed number of length 13 will have a length in your dump of 7, ( (13 + 1) / 2 ). The number 1234567890123 will have hex format: 
1357913 
246802x 

The part hex value 'x' is an sign indicator, (no sign, posative, negative). Sorry I do not know the ASCII vaues, EBCDIC values were F, C, D.

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

To read numeric values from ABAP Short dumps:

The value is saved in ASCII and Hexadecimal

Check Hexadecimal – In below screen shot – highlighted part
This value is split into 2 lines. You need to read highlighted below as 00025052517D – This value is actually equal to 250525.17- (negative – may be last ‘D’ represent –ve)




Friday, April 1, 2016

SLG1 Application logging


First go to SLG0 tcode, and setup Object 'ZCMS'

then put below code in your program

Check if CL_EZLOG exists in system - If not, use other way of setting up logs in http://sapist.blogspot.co.uk/2016/04/slg1-logging-program.html


DATA: lc_log TYPE REF TO CL_EZLOG.
  
* Start of CMS Logging
  CREATE OBJECT LC_LOG
    EXPORTING
      MSGOBJECT  = 'ZCMS'
      APPENDMODE = '1'
      INTERNAL   = 'X'.



    CALL METHOD LC_LOG->ADDMSG
      EXPORTING
        MSGTY = sy-msgty
        MSGID = sy-msgid
        MSGNO = sy-msgno
        MSGV1 = sy-msgv1
        MSGV2 = sy-msgv2
        MSGV3 = sy-msgv3.




  CALL METHOD LC_LOG->SAVE
    EXCEPTIONS
      EMPTY  = 1
      FAILED = 2
      others = 3.

  FREE lc_log.


Now, you can see in SLG1 - messages if any

Upgrade project steps


In our project we upgraded from ECC 6 EHP5 to EHP7 (unicode), we did in this sequence:
a) SPDD - done by Basis team at the time of basis changes for upgrade
b) SPAU - Mostly modified using Modification assistant. Some times we had to correct manually. Use Modif assistant - you can Insert/Replace code when needed. It's simple.
c) UCCHECK - done after Unicode installation by Basis -  We had to correct some programs and then tick 'Unicode enabled' for the programs and Acivate them.

Also, check below for steps (found in internet) - https://scn.sap.com/thread/3542865

   1. Unicode: This is done via UCCHECK transaction. You need to make all the programs (custom) unicode enable. For this you need to goto program attributes and check the box for unicode. Sometimes, after you enable unicode checking, some errors might occur, so you need to eliminate those.
     2. Obsolete FM: There might be some obsolete FMs in existing code (eg. WS_UPLOAD). So you need to replace those by new one (eg. GUI_UPLOAD)..
     3. Open dataset: Unfortunately I didn't get any chance to work upon these. Sorry.
     4. SPAU & SPDD: SPAU allows you to process Repository objects needing adjustment. But generally, ABAPers don't get chance to work upon these. PMs or TLs are preffered.     5. Conversion of script to smartforms: This totally depends on your customer, whether they want to convert all scripts to smartforms. Hope, you'll get some lists of scripts to convert. Just goto smartforms->utilities->migration->import sap script form. Might be you need to do some changes in program too for triggering this smartform properly.
     6. Enhancements: Depends on customer requirement. Might need to implement exits or BADIs as per requirement raised. Hope there will be hell lot of enhancements (I had to do a lot).

Tuesday, March 8, 2016

Idoc user exits - fetch item number from parent segment

 
Demo code for Idoc (EDI) user exits, where you don’t get item number in all segments.  This shows how to fetch item number from Parent segment (E1EDP01 in this case).
 
E1EDPA1 (Partner function segment in ORDERS idoc) does NOT have item number in it, So fetch from parent E1EDP01 (Item details) segment. To do that, write LOOP with  segnam = E1EDP01 or E1EDPA1 – demo code is shown below.
 
    LOOP AT int_edidd ASSIGNING <fs_edidd> WHERE segnam = 'E1EDP01'
                                             
OR  segnam = 'E1EDPA1'.

      
IF <fs_edidd>-segnam = 'E1EDP01'.
        
CLEAR : ls_e1edp01,
                lv_ebelp
.
        ls_e1edp01 
= <fs_edidd>-sdata.
        lv_ebelp   
=  ls_e1edp01-posex.
        
CONTINUE.
      
ENDIF.

      
CLEAR: ls_e1edpa1.
      
CHECK  <fs_edidd>-sdata+0(2) = 'WE'.
      ls_e1edpa1 
= <fs_edidd>-sdata.

      
REFRESH: lt_po_del_addr[].
*     Get  PO del address
      
CALL FUNCTION 'BAPI_PO_GETDETAIL1'
        
EXPORTING
          PURCHASEORDER    
= xekko-ebeln
          DELIVERY_ADDRESS 
= 'X'
        
TABLES
          POADDRDELIVERY   
= lt_po_del_addr.

*     Get Item PO delivery address
      
CLEAR: ls_po_del_addr.
      
READ TABLE lt_po_del_addr INTO ls_po_del_addr WITH KEY po_item = lv_ebelp.
      
IF sy-subrc EQ 0.
        ls_e1edpa1
-strs2 = ls_po_del_addr-str_suppl3.
        ls_e1edpa1
-pfach = ls_po_del_addr-location.
        <fs_edidd>
-sdata = ls_e1edpa1.
      
ENDIF.
    
ENDLOOP.
 

Thursday, February 4, 2016

FM to read Identification numbers from CRM Account overview


To get Identification numbers from CRM Account overview

Function module:  BAPI_IDENTIFICATIONDETAILS_GET

FM to read Marketing Attributes


1> Get Market Attribute Set List By

    call function 'CRM_MKTBP_READ_ALL_TPL' (Input is simply BP guid, output is listed of market attr set)
      

then call   
      call function 'CRM_MKTBP_READ_BP_DATA' by sending guid and market attribut set
The output will be the value list.