Thursday, 26 December 2013

Sample code for double click on output list using REUSE_ALV_GRID_DISPLAY , SAP or Interactive ALV

Do this:

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_top_of_page  = 'TOP-OF-PAGE'
      i_grid_title            = 'Title goes here'
      i_callback_program      = program
      i_grid_settings         = grid_setting
      i_callback_user_command = 'DOUBLE_CLICK_ON_ALV'
      is_layout               = alv_layout
      it_fieldcat             = i_fieldcat_alv
    TABLES
      t_outtab                = itab.



FORM double_click_on_ALV USING r_ucomm LIKE sy-ucomm
                                  rs_selfield TYPE slis_selfield.

  READ TABLE itab INDEX rs_selfield-tabindex.

  " now you can do what ever you like
  " with the above read statement you have the exact line
  " that the user selected. 
  " from here you can call FB03 or perform any other funciton

ENDFORM.         

Thursday, 21 November 2013

Authenticating User Login Details in SAP or Verifing Username and Password in SAP


SUSR_CHECK_LOGON_DATA  is the function module used to verify authentication 

Or 

 SUSR_LOGIN_CHECK_RFC , we can verify authentication.

Wednesday, 18 September 2013

How to Avoid Internal Commit or Implicit Commit in Standard BAPI

Below is the reply from SAP to avoid internal/implicit commit in standard Bapis : BAPIs BAPI_BATCH_CREATE, BAPI_BATCH_CHANGE, and
BAPI_BATCH_SAVE_REPLICA

Not sure whether this works for other standard Bapi's or not . We can try the below method given by SAP




BAPIs BAPI_BATCH_CREATE, BAPI_BATCH_CHANGE, and
BAPI_BATCH_SAVE_REPLICA can be used for maintaining batch data.
The three BAPIs mentioned above implicitly carry out a separate COMMIT
WORK.
If a COMMIT WORK AND WAIT is required, or if batch maintenance is to
be included om a transaction, the implicit COMMIT of the BAPIs has to
be suppressed.
This is done by calling function module 'TRANSACTION_BEGIN' before
calling the individual BAPI. Thus the calling program takes over
transaction control. The transaction is terminated by calling function
18.09.2013 Page 3 of 4
SAP Note 619913 - FAQ: Basic functions of batch
management
module 'TRANSACTION_END' or 'BAPI_TRANSACTION_COMMIT'.
BAPI_BATCH_CREATE
This BAPI exclusively serves for creating new batches or expanding
existing batches by plant or storage location segments.
BAPI_BATCH_CHANGE
This BAPI exclusively serves for changing existing batches.
BAPI_BATCH_SAVE_REPLICA
This BAPI creates batches or changes existing batches. It combines the
functions of the above-mentioned BAPIs.

Friday, 13 September 2013

Changing the import parameter of User Exit



DM07M is the input parameter of a user exit. Check the image for your information .

Declare a constant with main program in bracket followed by the field you want to change.
Example  : 
Constant : gc_temp type char30 value '(Main program name) Table-field' .

Field symbol : <FS> type table-field .

assign (gc_temp) to <FS> .

move the value required to field symbol.
Move 'Bharat' to <FS> .

Below is the example


  CONSTANTSgc_ref_fld TYPE char25 VALUE '(SAPMM07M)DM07M-KZCLA' .

FIELD-SYMBOLS<fs_wa> TYPE dm07m-kzcla.

ASSIGN (gc_ref_fldTO <fs_wa>.

IF <fs_wa> IS ASSIGNED.
*Do not show the characteristic screen...change to background mode
  MOVE '1' TO <fs_wa>.
ENDIF.




Wednesday, 11 September 2013

Wild Card Search in Select Statements

for suppose you need wild card search parameter like

data:patient(10)  type c.

search : a*

TRANSLATE  patient TO UPPER CASE.
replace all occurrences of  '*'  in patient with '%'.

select a
           b
           c
            into table itab
           where  A like patient.


With queries, I think its possible to use just the wild card '%'.
Say N%, then it retrieves data starting with N
%N% retrieves data which has N anywhere in between
%N retrieves data ending with N.

Thursday, 5 September 2013

Function module to find Differnce between two timestamps in Hours and minutes

SD_CALC_DURATION_FROM_DATETIME

This function module gives the time difference between two dates and time mentioned for each date.

Function module to get Number of Days per Month

NUMBER_OF_DAYS_PER_MONTH_GET

Lock Object ENQUEUE_E_TABLE

http://www.sapdev.co.uk/dictionary/lock_enqueue.htm


Example Program


Material and batch are primaly keys in table ZL009 , just use this two fields to lock a particular record in table.

FUNCTION z_insert_zl009.
*"----------------------------------------------------------------------
*"*"Update function module:
*"
*"*"Local interface:
*"  IMPORTING
*"     VALUE(I_ZL009) LIKE  ZL009 STRUCTURE  ZL009
*"----------------------------------------------------------------------
*  TABLES: *ZL009.
*
*  DATA: OBJECTID                TYPE CDHDR-OBJECTID,
*      TCODE                   TYPE CDHDR-TCODE,
*      PLANNED_CHANGE_NUMBER   TYPE CDHDR-PLANCHNGNR,
*      UTIME                   TYPE CDHDR-UTIME,
*      UDATE                   TYPE CDHDR-UDATE,
*      USERNAME                TYPE CDHDR-USERNAME,
*      CDOC_PLANNED_OR_REAL    TYPE CDHDR-CHANGE_IND,
*      CDOC_UPD_OBJECT         TYPE CDHDR-CHANGE_IND VALUE 'U',
*      CDOC_NO_CHANGE_POINTERS TYPE CDHDR-CHANGE_IND.
************************************************************************
* Change History                                                       *
* Date                   : 23-SEP-2009                                 *
* Modified By            : PARAKKAD                                    *
* Transport #            : D47K9A04G2                                  *
* Marked By              : @001                                        *
* ADT #                  : UNITY00004226                               *
* Description            : 6Fields added after SET command to update   *
*                          table zl009                                 *
************************************************************************
* Change History                                                       *
* Date                   : 2-DEC-2010                                  *
* Modified By            : CARRM5                                      *
* Transport #            : D47K9A0HKP                                  *
* Marked By              : D47K9A0HKP                                  *
* SCR #                  : 162999                                      *
* Description            : Track changes to ZL009-RevLv on ZREC_ZC21   *
*                          table                                       *
************************************************************************
************************************************************************
* Change History                                                       *
* Date                   : 06-Dec-2012                                 *
* Modified By            : GUPTAA8                                     *
* Transport #            : D47K9A0RM6                                  *
* Marked By              : D47K9A0RM6                                  *
* SCR #                  : 458943                                      *
* Description            : Revision Level Update for table ZL009 for   *
*                          all the Movement type for Tcode(MIGO & MB01)*
*                          & Mat.Grp.-010(Capital Equipment–BSC Mfg)   *
************************************************************************

* Begin Insert - D47K9A0HKP
  TABLESZREC_ZC21.
  DATA:   lc_matkl   TYPE   MATKL.
  CONSTANTS:  c_981(3TYPE C        VALUE '981',
              c_011(3TYPE C        VALUE '011',
              c_MIGO   TYPE TCODE    VALUE 'MIGO',
              c_MB01   TYPE TCODE    VALUE 'MB01',
              C_010(3TYPE C        VALUE '010'.    "D47K9A0RM6+
* End Insert - D47K9A0HKP

  DATA :  BEGIN OF lock_arg,
           mandt LIKE zl009-mandt,
           matnr LIKE zl009-matnr,
           charg LIKE zl009-charg,
   END OF lock_arg.
  DATA lock_arg-val  LIKE rstable-varkey.
  CLEAR lock_arg-val.
  CLEAR lock_arg.
  CLEAR zl009.
  MOVE-CORRESPONDING i_zl009 TO zl009.
  lock_arg-mandt sy-mandt.
  lock_arg-matnr zl009-matnr.
  lock_arg-charg zl009-charg.
  lock_arg-val lock_arg.
  CALL FUNCTION 'ENQUEUE_E_TABLE'
       EXPORTING
            mode_rstable   'S'
            tabname        'ZL009'
            varkey         lock_arg-val
**         X_TABNAME      = ' '
**         X_VARKEY       = ' '
            _scope         '2'
**         _WAIT          = ' '
       EXCEPTIONS
            foreign_lock   4
            system_failure 8
            OTHERS         3.

  CASE sy-subrc.
    WHEN 0.
    WHEN 4.
      MESSAGE a041 WITH lock_arg.
    WHEN OTHERS.
      MESSAGE a042 WITH  'ZL009'.
  ENDCASE.
  INSERT zl009.

  IF sy-subrc NE AND sy-subrc NE 4.
    MESSAGE a089 WITH 'ZL009' zl009-matnr zl009-charg.
*   System error : Error when inserting table &, Material no &, Batch no
  ENDIF.
  IF sy-subrc 4.
    UPDATE zl009
        SET
           ebeln =    zl009-ebeln
           mjahr =    zl009-mjahr
           ersda =    zl009-ersda
           ernam =    zl009-ernam
           revlv =    zl009-revlv
           werks =    zl009-werks
           bwart =    zl009-bwart
           vfdat =    zl009-vfdat
           lifnr =    zl009-lifnr
           licha =    zl009-licha
           aufnr =    zl009-aufnr
           zovwrit =  zl009-zovwrit
*********************** Begin Ins @001*****************
           zorigwerks =  zl009-zorigwerks
           zzsterlot  =  zl009-zzsterlot
           zzstldat   =  zl009-zzstldat
           zzstlloc   =  zl009-zzstlloc
           zzstlmthd  =  zl009-zzstlmthd
           zzproduct  =  zl009-zzproduct
********************* End Ins @001***********************
         WHERE
           matnr =    zl009-matnr  AND
           charg =    zl009-charg .

    IF sy-subrc NE 0.
      MESSAGE a089 WITH 'ZL009' zl009-matnr zl009-charg.
*   System error : Error when inserting table &, Material no &, Batch no
    ENDIF.

* Begin Insert - D47K9A0HKP
* The following code was lifted from MZC09F01 in transaction ZC21.
* We are inserting an entry in table ZREC_ZC21 to track RevLv history.
* We can only store the current value of ZL009-RevLv because at this
* point we have no access to previous value. We will store the current
* value in ZREC_ZC21-XVALUE. This table update occurs only when the
* transaction is MIGO or MB01, the movement is 981, and the material
* group is 011.
*    IF ZL009-BWART = c_981                             "D47K9A0RM6-
*    AND ( SY-TCODE = c_MIGO OR SY-TCODE = c_MB01 ).    "D47K9A0RM6-
    IF SY-TCODE c_MIGO OR SY-TCODE c_MB01 ).      "D47K9A0RM6+
      CLEAR lc_matkl.
      SELECT SINGLE MATKL INTO lc_matkl FROM MARA
        WHERE MATNR ZL009-MATNR.
*      IF lc_matkl = c_011.                             "D47K9A0RM6-
      IF lc_matkl c_011 OR LC_MATKL EQ C_010 ).     "D47K9A0RM6+
        CLEAR ZREC_ZC21.
        ZREC_ZC21-MANDT    SY-MANDT    .
        ZREC_ZC21-SYSID    SY-UNAME    .
        ZREC_ZC21-PLANT    ZL009-WERKS.
        ZREC_ZC21-MATNR  ZL009-MATNR.
        ZREC_ZC21-CHARG ZL009-CHARG.
        ZREC_ZC21-RECDATE  SY-DATUM.
        ZREC_ZC21-RECTIME  SY-UZEIT.
        ZREC_ZC21-ACTION   'MOD'.
        ZREC_ZC21-XTABLE   'ZL009'.
        ZREC_ZC21-XFIELD 'Revision'.
        ZREC_ZC21-XVALUE ZL009-REVLV.
        ZREC_ZC21-TCODE SY-TCODE.
        INSERT ZREC_ZC21.
      ENDIF.
    ENDIF.

* End Insert - D47K9A0HKP
  ENDIF.
******

  CALL FUNCTION 'DEQUEUE_E_TABLE'
       EXPORTING
            mode_rstable 'S'
            tabname        'ZL009'
            varkey         lock_arg-val
*         X_TABNAME    = ' '
*         X_VARKEY     = ' '
            _scope       '2'
            _synchron    'X'.
*********************************************************

*  OBJECTID = 'CHARGE'.
*  UDATE = SY-DATUM.
*  UTIME = SY-UZEIT.
*  TCODE = SY-TCODE.
*  USERNAME = SY-UNAME.
*  *ZL009  = ZL009.
*
*  CALL FUNCTION 'CHANGEDOCUMENT_OPEN'
*    EXPORTING
*      OBJECTCLASS      = 'CHARGE         '
*      OBJECTID         = OBJECTID
*    EXCEPTIONS
*      SEQUENCE_INVALID = 1
*      OTHERS           = 2.
*
*  CASE SY-SUBRC.
*    WHEN 1. MESSAGE A004 WITH 'Sequence invalid'.
*    WHEN 2. MESSAGE A004 WITH 'OPEN-Failure'.
*  ENDCASE.
*
*  CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'
*    EXPORTING
*      TABLENAME              = 'ZL009         '
*      WORKAREA_OLD           = *ZL009
*      WORKAREA_NEW           = ZL009
*      CHANGE_INDICATOR       = 'U'
*      DOCU_DELETE            = ' '
*    EXCEPTIONS
*      NAMETAB_ERROR          = 1
*      OPEN_MISSING           = 2
*      POSITION_INSERT_FAILED = 3
*      OTHERS                 = 4.
*
*  CASE SY-SUBRC.
*    WHEN 1. MESSAGE A004 WITH 'Name table failure'.
*    WHEN 2. MESSAGE A004 WITH 'Open missing'.
*    WHEN 3. MESSAGE A004 WITH 'INSERT failure'.
*    WHEN 4. MESSAGE A004 WITH 'SINGLE Failure'.
*  ENDCASE.
*
*  CALL FUNCTION 'CHANGEDOCUMENT_CLOSE'
*    EXPORTING
*      OBJECTCLASS          = 'CHARGE         '
*      OBJECTID             = OBJECTID
*      DATE_OF_CHANGE       = UDATE
*      TIME_OF_CHANGE       = UTIME
*      TCODE                = TCODE
*      USERNAME             = USERNAME
*    EXCEPTIONS
*      HEADER_INSERT_FAILED = 1
*      OBJECT_INVALID       = 2
*      OPEN_MISSING         = 3
*      NO_POSITION_INSERTED = 4
*      OTHERS               = 5.
*
*  CASE SY-SUBRC.
*    WHEN 1. MESSAGE A004 WITH 'Insert Header failed'.
*    WHEN 2. MESSAGE A004 WITH 'Object invalid'.
*    WHEN 3. MESSAGE A004 WITH 'Open missing'.
*    WHEN 5. MESSAGE A004 WITH 'CLOSE Failure'.
*  ENDCASE.


ENDFUNCTION.

Saturday, 17 August 2013

Move Data from Select-Options to Internal Table

  TABLES mara.

TYPES BEGIN OF ty_mat,
  matnr TYPE matnr,
  END OF ty_mat.
data gw_mat type ty_mat.
SELECT-OPTIONS mat FOR mara-matnr.


DATA itab TYPE STANDARD TABLE OF mara.
DATA it TYPE STANDARD TABLE OF matnr.

*MOVE mat[] TO it[] .

LOOP AT mat INTO gw_mat.

APPEND gw_mat+2 to it.
* Here we have added +2(offset) because every time IE or IEQ gets added. To remove this character we need to keep +2 or +3. if hte value is getting truncation in internal table IT, then increase the lenght of field in internaltable IT




CLEAR gw_mat.

ENDLOOP.

SELECT FROM mara INTO TABLE itab WHERE matnr IN mat.



CLEAR mat[].

mat[] it[] .


WRITE 'bharat' .

Sunday, 28 July 2013

Finding Funtion Group

We can find all FunctionGroup as below.

Goto Se11
Enter Table  TADIR
In table selection screen enter  OBJECT = FUGR, then you will get all the function groups.
If you want function groups created by a person , enter author name  in addition to OBJECT = FUGR

Standard Program to Delete Scheduled Jobs is RSBTCDEL

Standard Program to Delete Scheduled Jobs is RSBTCDEL.

Run this program in SE38, here you can delete all the jobs

Saturday, 22 June 2013

Using Perform of one program in Another program

Example :

  PERFORM f_add_ser_cond IN PROGRAM znm_sc_r_qn_erro_disp IF FOUND
                            TABLES    i_cond2
                                      t_serialno
                                      lt_sernr
                            USING     matnr
                                      vwerk
                                      aufart
                                      repos
                             CHANGING lv_flag.

Tuesday, 18 June 2013

User Exit Table MODSAP

1. MODSAP is the table which has Exit name .
2. When you have a include of an exit, use the where used list and find the EXIT name.
3. Pass the Exit name to the MODSAP , then you can find the Enhancement name.

Wednesday, 12 June 2013

Disable Fields in Selection Screen of Report Program based on Authority Check.

1.  First check for Required condition ( Checking authorization in  current example) in INITIALIZATION . Based on condition use LOOP AT SCREEN to disable or make the field invisible.

Example       
  INITIALIZATION.
gv_readonly_flag 'X' .
 LOOP AT SCREEN.

      IF screen-name EQ 'P_R1'.
        break mavb.
        screen-invisible '1'.
        screen-active '0' .
        MODIFY SCREEN.
      ENDIF.

    ENDLOOP.



2. Keep a flag when you run the above code and copy the same code in  AT SELECTION-SCREEN OUTPUT.  as initially the field will be invisible in the selection screen but when the user press ENTER, the field will become visible as INITIALIZATION will be executed only once in the life of program, so when the user press enter the field will become visible. So we have to write the same code in  AT SELECTION-SCREEN OUTPUT.
Example

  AT SELECTION-SCREEN OUTPUT.
  IF gv_readonly_flag 'X' .
    LOOP AT SCREEN.

      IF screen-name EQ 'P_R1'.
        break mavb.
        screen-invisible '1'.
        screen-active '0' .
        MODIFY SCREEN.
      ENDIF.

    ENDLOOP.

  ENDIF.



Example with a scenario for Authorisation check :

  SELECTION-SCREEN  BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS p_r1  RADIOBUTTON GROUP g1 ,
             p_r2  RADIOBUTTON GROUP g1 .

SELECTION-SCREEN END OF BLOCK b2.



  INITIALIZATION.

  CALL FUNCTION 'AUTHORITY_CHECK'
    EXPORTING
      user                sy-uname
      object              'ZQMCERTMGR'
      field1              'ZQMCRTACVT'
      value1              '01'
    EXCEPTIONS
      user_dont_exist     1
      user_is_authorized  2
      user_not_authorized 3
      user_is_locked      4
      OTHERS              5.

  IF sy-subrc NE 2.

    CALL FUNCTION 'AUTHORITY_CHECK'
      EXPORTING
        user                sy-uname
        object              'ZQMCERTMGR'
        field1              'ZQMCRTACVT'
        value1              '03'
      EXCEPTIONS
        user_dont_exist     1
        user_is_authorized  2
        user_not_authorized 3
        user_is_locked      4
        OTHERS              5.
    IF sy-subrc EQ .
      gv_readonly_flag 'X' .
    ELSEIF sy-subrc NE .
      MESSAGE 'User is not Authorised'(019TYPE 'E' .
      LEAVE TO LIST-PROCESSING.
      EXIT.
    ENDIF.
  ENDIF.

  IF gv_readonly_flag 'X' .

    LOOP AT SCREEN.

      IF screen-name EQ 'P_R1'.
        break mavb.
        screen-invisible '1'.
        screen-active '0' .
        MODIFY SCREEN.
      ENDIF.

    ENDLOOP.

  ENDIF.

AT SELECTION-SCREEN OUTPUT.
  IF gv_readonly_flag 'X' .
    LOOP AT SCREEN.

      IF screen-name EQ 'P_R1'.
        break mavb.
        screen-invisible '1'.
        screen-active '0' .
        MODIFY SCREEN.
      ENDIF.

    ENDLOOP.

  ENDIF.



Explanation : P_R1 and P_R2 are radion buttons. P_R1 is for write access and P_R2 is for read only report. So when we check for authorisation using the Authority_check function module, if user has authorisation for write access, authority FM with field value '01' will pass, if the user doesn't have write access , then we check for read access.If user has read access then we make the radio button P_R1 invisible as per above code.

Friday, 31 May 2013

OOPS ABAP Training Videos

oops website :-




below one is online tutorial of thomas jung:-


RM tiwary interesting blogs:-



Above links have been received from Pallav

Change Document CDHDR and CDPOS tables .

We can check the log in CDHDR and CDPOS tables or in transaction RSSCD100.



Below is to create a log in tables CDHDR and CDPOS for any table.

http://wiki.sdn.sap.com/wiki/display/ABAP/Change+Document

copy the below data from above link here.



CHANGE DOCUMENT:
This document briefly describes how to create a 'Change Document' for a business object.
Let us start with an example for clear understanding and to know the importance of the 'Change Document'.
  • Consider MM01 transaction, here MATNR is a primary key as well as 'Change Document Object'.
  • Now we try to create a Material in the MM01.
  • Now once we finish creating a material, we can find that a new material has been inserted not only from the MARA table or any other material related table but also from the tables 'CDHDR' or 'CDPOS'.The material we have created in 'CDHDR' table will be something like this.

Wednesday, 29 May 2013

Module Pool Normal Screen Length

Module Pool Normal Screen Length

height 200
width 255

i.e., Maintenance 200  255
Without Application tool bar check box should be checked.

Thursday, 23 May 2013

AT SELECTION-SCREEN ON SELECT_OPTIONS .

  SELECT-OPTIONS s_matnr FOR mara-matnr.       
OR
  SELECT-OPTIONS s_matnr FOR mara-matnr           NO INTERVALS.



  AT SELECTION-SCREEN ON s_matnr.
  PERFORM f_validate_matnr.



  *&---------------------------------------------------------------------*
*&      Form  F_VALIDATE_MATNR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_validate_matnr .
  DATA lv_matnr TYPE matnr.
  CHECK s_matnr[] IS NOT INITIAL.
  SELECT SINGLE matnr                                       "#EC *
             INTO lv_matnr
             FROM mara
            WHERE matnr IN s_matnr.

  CHECK sy-subrc IS NOT INITIAL.
  MESSAGE 'Enter a valid Material'(021TYPE 'E'.

ENDFORM.                    " F_VALIDATE_MATNR

Tuesday, 21 May 2013

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_werks , P_werks is parameter variable.

REPORT  YKC_SEARCH_HELP.
*internal table made to populate the value of werks when pressing f4
DATA: BEGIN OF IT_FINAL OCCURS 0,
      WERKS TYPE MARC-WERKS,
      END OF IT_FINAL.
data: IT_RETURN LIKE DDSHRETVAL OCCURS 0 WITH header line.
parameters: p_werks(10) type c.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_werks.
  select  werks from marc
  into table IT_FINAL.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*   DDIC_STRUCTURE         = ' '
      RETFIELD               = 'WERKS'   "field of internal table
     VALUE_ORG              = 'S'
    TABLES
      VALUE_TAB              = IT_FINAL
*   FIELD_TAB              =
     RETURN_TAB             = IT_R
ETURN
            .
 WRITE IT_RETURN-FIELDVAL TO P_WERKS.
  REFRESH IT_FINAL.

Tuesday, 14 May 2013

Offset Example


Below code gives the exact position of  Variable  J in the variable name.


PARAMETERS name TYPE LENGTH 26 DEFAULT 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
PARAMETERS TYPE LENGTH 10.

DATA TYPE i.

FIND IN name MATCH OFFSET k.


WRITE / name/ k.


In below Below code  M is the position of character that is printed when we enter  M.
Offset starts from '0' always.
Offset of A is 0 , B is 1....  Z is 25.


PARAMETERS name TYPE LENGTH 26 DEFAULT 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
PARAMETERS TYPE LENGTH 10.
PARAMETERS TYPE " give offset
DATA TYPE i.

FIND IN name MATCH OFFSET k.


WRITE / name/ k.
WRITE 'Offset at 'name+m(1.

Saturday, 11 May 2013

RUN Commands for Windows OS

RUN Commands !

1. Accessibility Controls - access.cpl
2. Accessibility Wizard - accwiz
3. Add Hardware Wizard - hdwwiz.cpl
... 4. Add/Remove Programs - appwiz.cpl
5. Administrative Tools - control admintools
6. Automatic Updates - wuaucpl.cpl
7. Bluetooth Transfer Wizard - fsquirt
8. Calculator - calc
9. Certificate Manager - certmgr.msc
10. Character Map - charmap
11. Check Disk Utility - chkdsk
12. Clipboard Viewer - clipbrd
13. Command Prompt - cmd
14. Component Services - dcomcnfg
15. Computer Management - compmgmt.msc
16. Control Panel - control
17. Date and Time Properties - timedate.cpl
18. DDE Shares - ddeshare
19. Device Manager - devmgmt.msc
20. Direct X Troubleshooter - dxdiag
21. Disk Cleanup Utility - cleanmgr
22. Disk Defragment - dfrg.msc
23. Disk Management - diskmgmt.msc
24. Disk Partition Manager - diskpart
25. Display Properties - control desktop
26. Display Properties - desk.cpl
27. Dr. Watson System Troubleshooting­ Utility - drwtsn32
28. Driver Verifier Utility - verifier
29. Event Viewer - eventvwr.msc
30. Files and Settings Transfer Tool - migwiz
31. File Signature Verification Tool - sigverif
32. Findfast - findfast.cpl
33. Firefox - firefox
34. Folders Properties - control folders
35. Fonts - control fonts
36. Fonts Folder - fonts
37. Free Cell Card Game - freecell
38. Game Controllers - joy.cpl
39. Group Policy Editor (for xp professional) - gpedit.msc
40. Hearts Card Game - mshearts
41. Help and Support - helpctr
42. HyperTerminal - hypertrm
43. Iexpress Wizard - iexpress
44. Indexing Service - ciadv.msc
45. Internet Connection Wizard - icwconn1
46. Internet Explorer - iexplore
47. Internet Properties - inetcpl.cpl
48. Keyboard Properties - control keyboard
49. Local Security Settings - secpol.msc
50. Local Users and Groups - lusrmgr.msc
51. Logs You Out Of Windows - logoff
52. Malicious Software Removal Tool - mrt
53. Microsoft Chat - winchat
54. Microsoft Movie Maker - moviemk
55. Microsoft Paint - mspaint
56. Microsoft Syncronization Tool - mobsync
57. Minesweeper Game - winmine
58. Mouse Properties - control mouse
59. Mouse Properties - main.cpl
60. Netmeeting - conf
61. Network Connections - control netconnections
62. Network Connections - ncpa.cpl
63. Network Setup Wizard - netsetup.cpl
64. Notepad - notepad
65. Object Packager - packager
66. ODBC Data Source Administrator - odbccp32.cpl
67. On Screen Keyboard - osk
68. Outlook Express - msimn
69. Paint - pbrush
70. Password Properties - password.cpl
71. Performance Monitor - perfmon.msc
72. Performance Monitor - perfmon
73. Phone and Modem Options - telephon.cpl
74. Phone Dialer - dialer
75. Pinball Game - pinball
76. Power Configuration - powercfg.cpl
77. Printers and Faxes - control printers
78. Printers Folder - printers
79. Regional Settings - intl.cpl
80. Registry Editor - regedit
81. Registry Editor - regedit32
82. Remote Access Phonebook - rasphone
83. Remote Desktop - mstsc
84. Removable Storage - ntmsmgr.msc
85. Removable Storage Operator Requests - ntmsoprq.msc
86. Resultant Set of Policy (for xp professional) - rsop.msc
87. Scanners and Cameras - sticpl.cpl
88. Scheduled Tasks - control schedtasks
89. Security Center - wscui.cpl
90. Services - services.msc
91. Shared Folders - fsmgmt.msc
92. Shuts Down Windows - shutdown
93. Sounds and Audio - mmsys.cpl
94. Spider Solitare Card Game - spider
95. SQL Client Configuration - cliconfg
96. System Configuration Editor - sysedit
97. System Configuration Utility - msconfig
98. System Information - msinfo32
99. System Properties - sysdm.cpl
100. Task Manager - taskmgr
101. TCP Tester - tcptest
102. Telnet Client - telnet
103. User Account Management - nusrmgr.cpl
104. Utility Manager - utilman
105. Windows Address Book - wab
106. Windows Address Book Import Utility - wabmig
107. Windows Explorer - explorer
108. Windows Firewall - firewall.cpl
109. Windows Magnifier - magnify
110. Windows Management Infrastructure - wmimgmt.msc
111. Windows Media Player - wmplayer
112. Windows Messenger - msmsgs
113. Windows System Security Tool - syskey
114. Windows Update Launches - wupdmgr
115. Windows Version - winver
116. Wordpad - write

Wednesday, 8 May 2013

Read multiple sheets of an Excel file into SAP through ABAP

copied from link

http://wiki.sdn.sap.com/wiki/display/Snippets/Read+multiple+sheets+of+an+Excel+file+into+SAP+through+ABAP

 

I couldn't find a good solution in ABAP to read data from multiple worksheets of an excel file. I developed this code using SAP classes and intefaces:  CL_GUI_CUSTOM_CONTAINER,I_OI_CONTAINER_CONTROL,I_OI_DOCUMENT_PROXY AND I_OI_SPREADSHEET.


*&---------------------------------------------------------------------*
*& Report  ZTEST_SOURAV_EXCEL
*&
*&---------------------------------------------------------------------*
*& Sourav Bhaduri 02-Dec-2008
*&---------------------------------------------------------------------*

REPORT  ztest_sourav_excel NO STANDARD PAGE HEADING.

DATA:
oref_container   TYPE REF TO cl_gui_custom_container,
iref_control     TYPE REF TO i_oi_container_control,
iref_document    TYPE REF TO i_oi_document_proxy,
iref_spreadsheet TYPE REF TO i_oi_spreadsheet,
iref_error       TYPE REF TO i_oi_error.

DATA:
v_document_url TYPE c LENGTH 256,
i_sheets TYPE soi_sheets_table,
wa_sheets TYPE soi_sheets,
i_data        TYPE soi_generic_table,
wa_data       TYPE soi_generic_item,
i_ranges      TYPE soi_range_list.

PARAMETERS:
p_file  TYPE  localfile OBLIGATORY,
p_rows TYPE i DEFAULT 100 OBLIGATORY, "Rows (Maximum 65536)
p_cols TYPE i DEFAULT 10 OBLIGATORY.    "Columns (Maximum 256)

INITIALIZATION.

  CALL METHOD c_oi_container_control_creator=>get_container_control
     IMPORTING
       control = iref_control
       error   = iref_error
*      retcode =
      .
  IF iref_error->has_failed = 'X'.
    CALL METHOD iref_error->raise_message
      EXPORTING
        type = 'E'.
  ENDIF.


  CREATE OBJECT oref_container
    EXPORTING
*      parent                      =
       container_name              = 'CONT'
*      style                       =
*      lifetime                    = lifetime_default
*      repid                       =
*      dynnr                       =
*      no_autodef_progid_dynnr     =
    EXCEPTIONS
       cntl_error                  = 1
       cntl_system_error           = 2
       create_error                = 3
       lifetime_error              = 4
       lifetime_dynpro_dynpro_link = 5
       OTHERS                      = 6.
  IF sy-subrc <> 0.
    MESSAGE e001(00) WITH 'Error while creating container'.
  ENDIF.

  CALL METHOD iref_control->init_control
    EXPORTING
*      dynpro_nr                = SY-DYNNR
*      gui_container            = ' '
       inplace_enabled          = 'X'
*      inplace_mode             = 0
*      inplace_resize_documents = ' '
*      inplace_scroll_documents = ' '
*      inplace_show_toolbars    = 'X'
*      no_flush                 = ' '
*      parent_id                = cl_gui_cfw=>dynpro_0
       r3_application_name      = 'EXCEL CONTAINER'
*      register_on_close_event  = ' '
*      register_on_custom_event = ' '
*      rep_id                   = SY-REPID
*      shell_style              = 1384185856
       parent                   = oref_container
*      name                     =
*      autoalign                = 'x'
    IMPORTING
       error                    = iref_error
*      retcode                  =
    EXCEPTIONS
       javabeannotsupported     = 1
       OTHERS                   = 2
          .
  IF iref_error->has_failed = 'X'.
    CALL METHOD iref_error->raise_message
      EXPORTING
        type = 'E'.
  ENDIF.

  CALL METHOD iref_control->get_document_proxy
    EXPORTING
*     document_format    = 'NATIVE'
      document_type      = soi_doctype_excel_sheet
*     no_flush           = ' '
*     register_container = ' '
     IMPORTING
       document_proxy     = iref_document
       error              = iref_error
*    retcode            =
      .
  IF iref_error->has_failed = 'X'.
    CALL METHOD iref_error->raise_message
      EXPORTING
        type = 'E'.
  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

* To provide F4 help for the file
  PERFORM sub_file_f4.

START-OF-SELECTION.

  CONCATENATE 'FILE://' p_file INTO v_document_url.

  CALL METHOD iref_document->open_document
    EXPORTING
      document_title   = 'Excel'
      document_url     = v_document_url
*     no_flush         = ' '
      open_inplace     = 'X'
*     open_readonly    = ' '
*     protect_document = ' '
*     onsave_macro     = ' '
*     startup_macro    = ''
*     user_info        =
    IMPORTING
      error            = iref_error
*     retcode          =
      .
  IF iref_error->has_failed = 'X'.
    CALL METHOD iref_error->raise_message
      EXPORTING
        type = 'I'.
    LEAVE LIST-PROCESSING.
  ENDIF.

  CALL METHOD iref_document->get_spreadsheet_interface
     EXPORTING
       no_flush        = ' '
    IMPORTING
      error           = iref_error
      sheet_interface = iref_spreadsheet
*     retcode         =
      .

  IF iref_error->has_failed = 'X'.
    CALL METHOD iref_error->raise_message
      EXPORTING
        type = 'I'.
    LEAVE LIST-PROCESSING.
  ENDIF.

  CALL METHOD iref_spreadsheet->get_sheets
      EXPORTING
       no_flush = ' '
*      updating = -1
     IMPORTING
       sheets   = i_sheets
       error    = iref_error
*      retcode  =
      .
  IF iref_error->has_failed = 'X'.
    CALL METHOD iref_error->raise_message
      EXPORTING
        type = 'I'.
    LEAVE LIST-PROCESSING.
  ENDIF.
  LOOP AT i_sheets INTO wa_sheets.
    CALL METHOD iref_spreadsheet->select_sheet
       EXPORTING
          name     = wa_sheets-sheet_name
*         no_flush = ' '
      IMPORTING
          error    = iref_error
*         retcode  =
            .
    IF iref_error->has_failed = 'X'.
      EXIT.
*      call method iref_error->raise_message
*        exporting
*          type = 'E'.
    ENDIF.
    CALL METHOD iref_spreadsheet->set_selection
      EXPORTING
        top     = 1
        left    = 1
        rows    = p_rows
        columns = p_cols.

    CALL METHOD iref_spreadsheet->insert_range
      EXPORTING
        name     = 'Test'
        rows     = p_rows
        columns  = p_cols
        no_flush = ''
      IMPORTING
        error    = iref_error.
    IF iref_error->has_failed = 'X'.
      EXIT.
*      call method iref_error->raise_message
*        exporting
*          type = 'E'.
    ENDIF.

    REFRESH i_data.

    CALL METHOD iref_spreadsheet->get_ranges_data
       EXPORTING
*        no_flush  = ' '
         all       = 'X'
*        updating  = -1
*        rangesdef =
       IMPORTING
         contents  = i_data
         error     = iref_error
*        retcode   =
       CHANGING
         ranges    = i_ranges
             .
    DELETE i_data WHERE value IS INITIAL OR value = space.
    ULINE.
    WRITE:/1 wa_sheets-sheet_name COLOR 3.
    ULINE.

    LOOP AT i_data INTO wa_data.
      WRITE:(50) wa_data-value.
      AT END OF row.
        NEW-LINE.
      ENDAT.
    ENDLOOP.
  ENDLOOP.

  CALL METHOD iref_document->close_document
*  EXPORTING
*    do_save     = ' '
*    no_flush    = ' '
     IMPORTING
       error       = iref_error
*    has_changed =
*    retcode     =
      .
  IF iref_error->has_failed = 'X'.
    CALL METHOD iref_error->raise_message
      EXPORTING
        type = 'I'.
    LEAVE LIST-PROCESSING.
  ENDIF.
  CALL METHOD iref_document->release_document
*  EXPORTING
*    no_flush = ' '
     IMPORTING
       error    = iref_error
*    retcode  =
      .
  IF iref_error->has_failed = 'X'.
    CALL METHOD iref_error->raise_message
      EXPORTING
        type = 'I'.
    LEAVE LIST-PROCESSING.
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  SUB_FILE_F4
*&---------------------------------------------------------------------*
*       F4 help for file path
*----------------------------------------------------------------------*
FORM sub_file_f4 .
  DATA:
  l_desktop       TYPE string,
  l_i_files       TYPE filetable,
  l_wa_files      TYPE file_table,
  l_rcode         TYPE int4.

* Finding desktop
  CALL METHOD cl_gui_frontend_services=>get_desktop_directory
    CHANGING
      desktop_directory    = l_desktop
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4.
  IF sy-subrc <> 0.
    MESSAGE e001(00) WITH
        'Desktop not found'.
  ENDIF.

* Update View
  CALL METHOD cl_gui_cfw=>update_view
    EXCEPTIONS
      cntl_system_error = 1
      cntl_error        = 2
      OTHERS            = 3.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
     EXPORTING
       window_title            = 'Select Excel file'
       default_extension       = '.xls'
*      default_filename        =
       file_filter             = '.xls'
*      with_encoding           =
       initial_directory       = l_desktop
*      multiselection          =
    CHANGING
      file_table              = l_i_files
      rc                      = l_rcode
*     user_action             =
*     file_encoding           =
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5
          .
  IF sy-subrc <> 0.
    MESSAGE e001(00) WITH 'Error while opening file'.
  ENDIF.

  READ TABLE l_i_files INDEX 1 INTO l_wa_files.
  IF sy-subrc = 0.
    p_file = l_wa_files-filename.
  ELSE.
    MESSAGE e001(00) WITH 'Error while opening file'.
  ENDIF.

ENDFORM.                    " SUB_FILE_F4