Wednesday 17 June 2015

How to record the table log changes?

------------------------------------------------------------------------------------------------------------------------------------
Step1. Here is a table.


Step2. In the technical setting of the table, check the Log data changes.

Step3. So we have the maintenance view on the table.

Step4. Go to Tx- SM30 and maintain some new record or change some values of the existing record.


Step5. Then From the Menu option->Utilities-> Change log , select to see all the changes.


Step6. Give a change log period and the type of display and execute.

Step7. So here we have the change log appeared as old value and new value.





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





Function Module that returns any type of Total/Free Work Process in the system!


----------------------------------------------------------------------------------------------------------------------------------
DATA :   lv_wps TYPE i,
              lv_dia_wps TYPE i,
              lv_fdia_wps TYPE i,
              lv_btc_wps TYPE i,
              lv_fbtc_wps TYPE i.

CALL FUNCTION 'TH_COUNT_WPS'
* EXPORTING
*   SERVER              =
 IMPORTING
   wps                       lv_wps
   dia_wps                lv_dia_wps " available dialog work process
   free_dia_wps        lv_fdia_wps " currently free work process
*   UPD_WPS             =
*   FREE_UPD_WPS        =
*   ENQ_WPS             =
*   FREE_ENQ_WPS        =
   btc_wps                lv_btc_wps " available background workprocess
   free_btc_wps        lv_fbtc_wps " currently free workprocess
*   SPO_WPS             =
*   FREE_SPO_WPS        =
*   UPD2_WPS            =
*   FREE_UPD2_WPS       =
*   RES_WPS             =
*   DYN_WPS             =
*   DYN_WPS_USED        =
*   CONF_WPS            =
 EXCEPTIONS
   failed              1
   OTHERS              2.

WRITE :'TOtal Number of Work Process:'lv_wps.
WRITE :'TOtal Number of available Dialog Work Process:',  lv_dia_wps.
WRITE :'TOtal Number of free Dialog Work Process:'lv_fdia_wps.
WRITE :'TOtal Number of available Background Work Process:'lv_btc_wps.
WRITE :'TOtal Number of free Background Work Process:'lv_fbtc_wps.


----------------------------------------------------------------------------------------------------------------------------------
Step1. Execute the program.






 Step2. Go to Tx- SM50 and see all the work process details.

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

Function Module that provides number of available Dialog Work Process in system?

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

Many a times in development, need to implement asynchronous parallel processing to speed up the execution but unfortunately we can not spread as many number of parallel threads in the program as we have a limited number of dialog work processes. So maximum parallel threads we can create that depends on the currently free/available work processes. So we can use the FM to get the free dialog work process at the run time.
---------------------------------------------------------------------------------------------------------------------------------
DATA lv_max_dwp TYPE i,
             lv_free_dwp type i.

CALL FUNCTION 'SPBT_INITIALIZE'
* EXPORTING
*   GROUP_NAME                           = ' '
 IMPORTING
   max_pbt_wps                          =  lv_max_dwp
   free_pbt_wps                         =  lv_free_dwp
 EXCEPTIONS
   invalid_group_name                        1
   internal_error                                 2
   pbt_env_already_initialized            3
   currently_no_resources_avail         4
   no_pbt_resources_found                 5
   cant_init_different_pbt_groups       6
   OTHERS                                            7.

WRITE :'Maximum Dialog Work Processes available in the server:'lv_max_dwp.
WRITE :'Free Dialog Work Processs available in the server:'lv_free_dwp.


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









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


Tuesday 16 June 2015

Maintenance View - How to change maintenance view screen?

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

Step1. We have a customizing table with some fields.

Step2. For the third field some domain fixed values.



Step3. Create a maintenance view.



Step4. Add all the fields and generate the TMG of the maintenance view.




Step5.  So the TMG is created with two step type.



Step6. Now click on contents or go to Tx- SM30 and open the view to maintain.


Step7. Click on new entries.


Step8. So initially If you select or deselect the check box the approval type field is editable.
Now we have the requirement like when the check box is selected the approval type field should editable and when the checkbox is deselected then the approval field is non editable.



Step9.



Step10. Form the same screen , from system -> status.


Step11. Double click on the screen number - 2.


Step12. So here the flow logic automatically created when the TMG is generated. here we have to add our own logic for the above requirement.


Step13. Click on Layout.


Step14. Click on change mode. Double click on the check box, provide the text and function code. Activate and lastly click on Flow Logic button.


Step15. Now click on edit button. Add a new module in the PBO. Go on display mode.


Step16. Double click on the Module and from the pop up confirmation click YES to continue.


Step17. yes to continue.


Step18.Yes to continue.


Step19. So here we arrived.


Step20. Put the below code.


Step21. Activate the module and go back.


Step22. From the Maintenance view TMG mark the Function group name.


Step23. Go to Tx- SE80 and open the function group. Double click on the function group name and its status is inactive.


Step24. Right click on the Function group name and activate it.


Step25. Again double click on the function group name and from the pop up choose Main Program.



Step26. Here the include program. In side that we  have defined our Module .

Step27. So here it is.



Step28. No go to Tx- SM30 and open the maintenance view.

Step29. Click on New Entries.

Step30. So here we are. initially the allowed check box is not selected  , so the approval type field is disabled.


Step31. Once selected, the approval type field is enabled.







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


Monday 8 June 2015

String Function? Boolc ()

-----------------------------------------------------------------------------------------------------------------------------------
Code:
-----------------------------------------------------------------------------------------------------------------------------------
" BOOLC( )- Returns True(X) or False( ) for a given expresssion
DATA ret.
ret boolcsy-batch IS  INITIAL ).
WRITE ret.

-----------------------------------------------------------------------------------------------------------------------------------
Step1.

Step2. Output:

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

String Function? Repeat

-----------------------------------------------------------------------------------------------------------------------------------
Code:
--------------------------------------------------------------------------------------------------------------------------
* String Repeat *
DATA :   str1  TYPE string VALUE 'XYZ',
              str2  TYPE string,
              times TYPE i  VALUE 5.

WRITE :' Before string Repeat:'str1.
str2 repeatval str1 occ times ).   "repeats the string 5 times

WRITE :'After string Repeat :'str2.

--------------------------------------------------------------------------------------------------------------------------
Step1.

Step2. Output:


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

String Function? Reverse

---------------------------------------------------------------------------------------------------------------------------------
Code:
--------------------------------------------------------------------------------------------------------------------------
* String Reverse *
DATA str1 TYPE string VALUE 'SAP ABAP PROGRAM',
            str2 TYPE string VALUE ''.

WRITE :'Before Reverse:'str1.

str2 reversestr1 ). " reverse () function in ABAP

WRITE :'Aftre Reverse:'str2.

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



















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

String Functions? String Compares!

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

Comparisons can be applied on strings with types C, D, N, and T.




<operator>


Meaning


CO


Contains Only


CN


Contains Not only


CA


Contains Any


NA


contains Not Any


CS


Contains String


NS


contains No String


CP


Contains Pattern


NP


contains No Pattern


CO- Contains Only
 -------------------------------------------------------------------------------------------------------------------------
* contains only: true, if operand1 only contains characters from operand2.
* it is case-sensitive and trailing blanks are respected in both operands.
*IF the comparison IS  false, sy-fdpos contains the offset
* of the first character in operand1 that is not contained in operand2.
* IF the comparison IS true, sy-fdpos contains the length of operand1.


DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.

IF 'GRA' CO res.
  WRITE :'Success'sy-fdpos" Success -> sy-fdpos = strlen ( 'GRA' )
ELSE.
  WRITE :'Failure'sy-fdpos.
ENDIF.
ULINE.
IF 'GRAPX' CO res.
  WRITE :'Success'sy-fdpos.
ELSE.
  WRITE :'Failure'sy-fdpos" Failure-> sy-fdpos = offset position of X
ENDIF.

-----------------------------------------------------------------------------------------------------------------------
Output:

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

CN Contains Not Only
-----------------------------------------------------------------------------------------------------------------------
* contains not only->
* If true, sy-fdpos contains the offset of the first
* character in operand1 that is not contained in operand2.
* If false, sy-fdpos contains the length of operand1.

DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.

IF 'GRA' CN res.
  WRITE :'Success'sy-fdpos.
ELSE.
  WRITE :'Failure'sy-fdpos" Failure-> sy-fdpos = strlen ( 'GRA' )
ENDIF.
ULINE.
IF 'GRAPX' CN res.
  WRITE :'Success'sy-fdpos" Success -> sy-fdpos = offset position of X
ELSE.
  WRITE :'Failure'sy-fdpos.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------
Output:


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

CA- Contains Any
-----------------------------------------------------------------------------------------------------------------------
* contains any->
* True, if operand1 contains at least one character from operand2.
* then sy-fdpos contains the offset of the first character in operand1
* that is also contained in operand2
* If the comparison is false, sy-fdpos contains the length of operand1.

DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.

IF 'ZYGRA' CA res.
  WRITE :'Success:'sy-fdpos" Success -> sy-fdpos = offset OF 'G'
ELSE.
  WRITE :'Failure:'sy-fdpos.
ENDIF.
ULINE.
IF 'YX' CA res.
  WRITE :'Success:'sy-fdpos.
ELSE.
  WRITE :'Failure:'sy-fdpos" Failure-> sy-fdpos = strlen ( 'GRA' )
ENDIF.

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

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

NA- Contains Not Any
-----------------------------------------------------------------------------------------------------------------------
* contains not any->
* True, if operand1 does not contain any characters from operand2.
* If the comparison is false,sy-fdpos contains the offset of the first
* character in operand1 that is also contained in operand2.
* If the comparison is true, sy-fdpos contains the length of operand1.

DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.

IF 'ZYGRA' NA res.
  WRITE :'Success:'sy-fdpos.
ELSE.
  WRITE :'Failure:'sy-fdpos" Failure-> sy-fdpos = offset of 'G'
ENDIF.
ULINE.
IF 'YXZ' NA res.
  WRITE :'Success:'sy-fdpos"Success -> sy-fdpos = STRLEN ( 'YXZ' )
ELSE.
  WRITE :'Failure:'sy-fdpos.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------

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

CS- Contains String
-----------------------------------------------------------------------------------------------------------------------
* contains String->
* True, if operand1 contains the string in operand2 and not case sensitive
* If the comparison is false,sy-fdpos contains the length of operand1
* If the comparison is true, sy-fdpos contains the  offset of the operand2 in operand1

DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.

IF RES CS 'PrO'.
  WRITE :'Success:'sy-fdpos.  "Success -> sy-fdpos = Offset of 'P' in res
ELSE.
  WRITE :'Failure:'sy-fdpos.
ENDIF.
ULINE.
IF RES CS 'YXZ'.
  WRITE :'Success:'sy-fdpos.
ELSE.
  WRITE :'Failure:'sy-fdpos" Failure-> sy-fdpos = strlen ( res )
ENDIF.
-----------------------------------------------------------------------------------------------------------------------

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

NS- Contains No String
-----------------------------------------------------------------------------------------------------------------------
* contains no string->
* True, If operand1 does not contains the string operand and not case sensitive
* If the comparison is TRUE,sy-fdpos contains the length of operand1
* If the comparison is FALSE, sy-fdpos contains the  offset of the operand2 in operand1

DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.

IF res NS  'PrO'.
  WRITE :'Success:'sy-fdpos.
ELSE.
  WRITE :'Failure:'sy-fdpos" Failure-> sy-fdpos =  offset of 'P' in res
ENDIF.
ULINE.
IF res NS 'YXZ'.
  WRITE :'Success:'sy-fdpos.  "Success -> lengeth of ( res )
ELSE.
  WRITE :'Failure:'sy-fdpos.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------

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

CP- Contains Pattern
-----------------------------------------------------------------------------------------------------------------------
* contains Pattern->
* True, If operand1 contains pattern operand2 and not case sensitive
* If the comparison is TRUE,sy-fdpos contains the offset of operand2 in operand
* If the comparison is FALSE, sy-fdpos contains the length of operand1

DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.

IF res CP  '*Ro*'.
  WRITE :'Success:'sy-fdpos"Success ->  sy-fdpos = Offset of 'R' in res
ELSE.
  WRITE :'Failure:'sy-fdpos.
ENDIF.
ULINE.
IF res CP '*XY*'.
  WRITE :'Success:'sy-fdpos.
ELSE.
  WRITE :'Failure:'sy-fdpos" Failure-> sy-fdpos =  length of ( res )
ENDIF.
-----------------------------------------------------------------------------------------------------------------------

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

NP- Contains No Pattern
-----------------------------------------------------------------------------------------------------------------------
* contains no Pattern->
* True, If operand1 does not contains pattern operand2 and not case sensitive
* If the comparison is TRUE,sy-fdpos contains the length of operand1
* If the comparison is FALSE, sy-fdpos contains the offset of operand2 in operand1

DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.

IF res NP  '*Ro*'.
  WRITE :'Success:'sy-fdpos.
ELSE.
  WRITE :'Failure:'sy-fdpos.  " Failure-> sy-fdpos =   Offset of 'R' in res
ENDIF.
ULINE.
IF res NP '*XY*'.
  WRITE :'Success:'sy-fdpos.  "Success ->  sy-fdpos =  length of ( res )
ELSE.
  WRITE :'Failure:'sy-fdpos.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------

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

Comments system

Disqus Shortname