Tuesday, January 24, 2012

ABAP: Display ALV without creating screens/containers


In traditional approach we always define a container areas and then pout the ALV in this container.
But the same can also be achieved by making use of static methods of container classes.
e.g
Data lr_grid type ref to cl_gui_alv_grid.

  CREATE OBJECT lr_grid
      EXPORTING
           i_parent = cl_gui_custom_container=>screen0.
                        or cl_gui_container=>default_screen.
 " instead of creating custom container you can use standard screens

lr_grid->set_table_for_first_display( .... ).

This is a simple example and you can do lot more stuff with standard functions or think of using SALV.

Cheers,
Sandeep

Monday, January 23, 2012

ABAP: Things to consider for CHAR type fields in tables

If you are enhancing your table structure with CHAR type data elements,  there are few things which you must consider.

If the newly added field is NOT a key field and you have not marked the field for Initial Values = 'X'.


1. If you check values in this field in your programs you cannot be sure that the condition “IS INITIAL” or “IS SPACE” is working correctly. Same holds for comparisons with other variables having a SPACE or INITIAL value.


2. If you need to check for an initial value in this field you should make sure to use the condition ( IS INITIAL OR IS NULL) as depending on DB system a NULL value is stored.


3. If you use this field to store character strings w/o usage in SAP GUI screen fields that’s OK. However, when you use it on SAP GUI screens you cannot use lowercase characters as it is not based on a domain with lowercase option. So an automatic uppercase conversion is done when a screen input is used.

Cheers,
Sandeep 


Sunday, January 22, 2012

Tables for Partner Profiles

The partner profiles are stored in the following tables:

    o  Table EDPP1: General partner profile

    o  Table EDP12: Partner profile outbound, additional data NAST

    o  Table EDP13: Partner profile outbound

    o  Table EDP21: Partner profile inbound

•Table EDIPHONE: Connection to SAP telephony (optional)

This info may help if your are developing any reports related to profiles or trying to find some info for the same.

Cheers,
Sandeep 

Friday, January 20, 2012

ABAP: How to read application server name in abap

We can see the list of all application servers via SM51 txn.

It's very easy to find the Application server host name and you can find the same using the SYST parameters( SY-HOST).

But at times, there are requirements to show/display the actual name of the application server.
Here is a simple code for the same using C Functions within ABAP.

  call 'C_SAPGPARAM' id 'NAME'  field 'rdisp/myname'
                                     id 'VALUE' field lv_current_server.

Cheers,
Sandeep 


ABAP: Count number of code lines in METHODS

As you know it's pretty easy to count the no. of code lines for Include/Module/Report programs, you have to simply use statement READ REPORT and you are done.
But in case of counting the code lines in class methods it's a bit.

The same can be achieved by following simple steps:

1.     Do a select on TADIR for the class name as obj_name and build the object range with 'I' 'EQ' and low as 'CLAS'.

2.     Find all the class include using FM: SEO_CLASS_GET_METHOD_INCLUDES ( pass clskey = clsname)
e.g CALL FUNCTION 'SEO_CLASS_GET_METHOD_INCLUDES'
           EXPORTING
            clskey                       = is_class_key
          IMPORTING
            includes                     = it_class_incl
          EXCEPTIONS
            _internal_class_not_existing = 1
            OTHERS                       = 2.
        IF sy-subrc <> 0.
          CONTINUE.
        ENDIF.

3.     Build  the sub_name internal table using it_class_incl-cpdkey-cpdname.

4.     Get the source code using FM : SEO_METHOD_GET_SOURCE
e.g  CALL FUNCTION 'SEO_METHOD_GET_SOURCE'
        EXPORTING
          mtdkey                              = is_class_cmp
        IMPORTING
          source_expanded                     = it_class_code
        EXCEPTIONS
          _internal_method_not_existing       = 1
          _internal_class_not_existing        = 2
          version_not_existing                = 3
          inactive_new                        = 4
          inactive_deleted                    = 5
          OTHERS                              = 6.
      IF sy-subrc <> 0.
        CONTINUE.
      ENDIF.

5.     After this you have the source code in lt-class_code and do a COUNT.
e.g       is_result-count LINES( it_class_code ). "initial count
      
LOOP AT it_class_code ASSIGNING .
        
IF  IS INITIAL.
          
DELETE it_class_code.
        
ELSE.
          
IF (1) = '*'.
            
DELETE it_class_code.
          
ENDIF.
        
ENDIF.
      
ENDLOOP.
       is_result
-count_check LINES( it_class_code ). " without comments
      
LOOP AT it_class_code ASSIGNING .
        
FIND '.' IN .
        
IF sy-subrc <> 0.
          
FIND ',' IN .
          
IF sy-subrc <> 0.
            
DELETE it_class_code.
          
ENDIF.
        
ENDIF.
      
ENDLOOP.
  is_result-count_check_final LINES( it_class_code )."final count 

Cheers,
Sandeep 

Thursday, January 19, 2012

ABAP: Append structure to a table and status is “partially active”


Most often at customer sites one can get in trouble as they want to enhance a table and at times the length of table fields is more than what SAP supports and the appended structure is not activating fully in other words... "partially active" status.

The limit for field length mentioned is 4030 bytes as of basis release 620 SP25.

Even though it has partially active status we can add data and retrieve data from database but its flag an error "inconsistency persist".


In such situations the below tips can make life easy :

You can either execute report TOUCHTAB - Generate Program After Structure Changes in R/3 Repository to bump the limit whatever your database supports

OR

Change the DB Constants for Tables  using report RADTBCON.

Note:  As per SAP, "We recommend that you do not extend it any further than this. See note 636217. For detailed information, see note 355898 (Restrictions for transparent tables)".

Hope this helps.

Cheers,
Sandeep

ABAP: Store and read data from clusters

Hello,

Here is a simple program to store and read data from the clsuter.

* Create a transperant table , copy structure of table INDX.

DATA: it_info TYPE string,
      is_key(4) .

it_info 'Test to save data to INDX'.
is_key 'TEST'.

* Export to DB clsuter
EXPORT   gs_info    FROM it_info
         TO DATABASE zsandy_test(sy)
         ID is_key.

CLEAR it_info.

* Import from DB cluster.
IMPORT gs_info     it_info
         FROM DATABASE zsandy_test(sy)
         ID is_key.

WRITE:/ it_info. " this will show the record which is inserted with EXPORT

This is for the beginners :)

Cheers,
Sandeep

IMG extenisons in SPRO

The following steps would help you add a node to SPRO:

1. Node creation:

- Use transaction S_IMG_EXTENSION and select the IMG structure that youu want to extend.

- Create a new enhancement and select the same and click on option ENHANCE STRUCTURE.

- Navigate to the point where you need the node and click on icon create activity

- Give the IMG ACTIVITY ID and NAME .

- Provide an ID and name in the tab MAINTAIN OBJECTS and give the object description in the same.

- Eg : If a maintenace view, enter the customizing object name as the view name, type as V and the transaction as SM30 and save.

2. Add supporting help documentation for the node:

-Use the tab DOCUMENTATION and create a document. I

- To insert hyperlinks in the documentation which are mapped to the data element documentation (same as SAP standard).

-Use LINK option in the INSERT menu in the documentation window.

-Select ‘Data element’ option from the drop down

-Provide the data element name to create the hyperlink.

Important Txns in Archive for Abapers

You always wonder what Archive is all about and where abapers are asked to pitch-in , well here is short list of transactions which might help you to start with.

AS_AFB : Archive file browser

AS_ADMIN : Archive Administration

AOBJ : view maintenance for archive objects

SARA : Archive administation

SARI : Archive info. system - central management

ALO1 : search for documents with relationships inc archive

To check the info structure for a session : SARI-> customizing->provide archive info. -> check Technical data ( this is a structure in db)

FM: KASH_ARCHIVE_DATA_OBJECT_SHOW to check archive files data