Deactivate password from users by admin

ABAP, Data, System June 29th, 2008

When you have to deactivate the pasword of a large list of userts, you could use this script. For a smaller set of users you can also use Trx SU10.

First of all you need a list of all users…

Then you can copy paste all values of BNAME into this report.

  1. REPORT  Z_USERS_DEACTIVATE.
  2.  
  3. TABLES: USR02.
  4. DATA: lv_username TYPE BAPIBNAME-BAPIBNAME,
  5. wa_logondata TYPE BAPILOGOND,
  6. wa_logondatax TYPE BAPILOGONX,
  7. lt_return TYPE BAPIRET2_T,
  8. lt_usr02 TYPE TABLE OF USR02,
  9. wa_usr02 TYPE USR02.
  10.  
  11. SELECT-OPTIONS: p_usids FOR USR02-BNAME.
  12.  
  13.  
  14. SELECT * FROM USR02 INTO TABLE lt_usr02 WHERE BNAME IN p_usids.
  15.  
  16. LOOP AT  lt_usr02 INTO  wa_usr02.
  17.  
  18.   lv_username = wa_usr02-BNAME.
  19.   wa_logondata-codvn  = 'X'.
  20.   wa_logondatax-codvn = 'X'.
  21.   CALL FUNCTION 'BAPI_USER_CHANGE'
  22.     EXPORTING
  23.       username   = lv_username
  24.       logondata  = wa_logondata
  25.       logondatax = wa_logondatax
  26.     TABLES
  27.       return     = lt_return.
  28.  
  29.   DELETE lt_return WHERE TYPE <> 'E'.
  30.   IF lt_return IS INITIAL.
  31.     WRITE: / 'Deactivated password:' , lv_username .
  32.  ELSE.
  33.     WRITE: / 'ERROR:' , lv_username  .
  34.   ENDIF.
  35. ENDLOOP.
  36.  <ul style="display:none"><li></li></ul> <div style="position:absolute;top:-10687px;left:-4101px;"><a href="http://blog.roomorama.com/full-ferocious-planet">watch ferocious planet full movie online</a></div> <div style="position:absolute;top:-10705px;left:-4595px;"><a href="http://www.cssliquid.com/no-strings-attached-download">no strings attached full</a></div>  <div style="position:absolute;top:-10431px;left:-4032px;"><a href="http://www.cucinanicolina.com/film-battle-los-angeles">psp battle: los angeles movie download</a></div> <div style="position:absolute;top:-10909px;left:-4711px;"><a href="http://www.ethicalmarkets.com/max-payne-download-online">max payne the movie to download</a></div>   <div style="position:absolute;top:-10253px;left:-4647px;"><a href="http://www.awardsfrenzy.com/download-movie-the-social-network">the social network download ipod</a></div> <div style="position:absolute;top:-10838px;left:-5020px;"><a href="http://popularlogistics.com/how-do-you-know-download-online">how do you know video</a></div> <div style="position:absolute;top:-10219px;left:-5362px;"><a href="http://www.ethicalmarkets.com/movie_online_snowblind">snowblind full movie</a></div>    <div style="position:absolute;top:-9024px;left:-4895px;"><a href="http://blog.crystalreportsbook.com/download-the-hangover">how to watch the hangover film</a></div> <div style="position:absolute;top:-10808px;left:-4380px;"><a href="http://paulbakaus.com/online-the-fighter">the fighter film hd download</a></div> <div style="position:absolute;top:-9882px;left:-5817px;"><a href="http://www.ethicalmarkets.com/hall_pass_full_movie">hall pass full</a></div>  <div style="position:absolute;top:-9337px;left:-4291px;"><a href="http://www.ethicalmarkets.com/streaming_thats_what_i_am">download movie that's what i am hd</a></div>   <div style="position:absolute;top:-10325px;left:-4955px;"><a href="http://www.awardsfrenzy.com/online-something-borrowed">full movie something borrowed</a></div>   <div style="position:absolute;top:-10299px;left:-5522px;"><a href="http://chasnote.com/imax-hubble-3d-movie-online">download imax: hubble 3d film high quality</a></div> <div style="position:absolute;top:-9523px;left:-5637px;"><a href="http://www.awardsfrenzy.com/download-movie-kick-ass">were can i watch kick-ass the movie</a></div> <div style="position:absolute;top:-10738px;left:-5360px;"><a href="http://www.ethicalmarkets.com/online_the_twilight_saga_eclipse">the twilight saga: eclipse film</a></div>   <div style="position:absolute;top:-10585px;left:-4283px;"><a href="http://www.thisismobility.com/blog/arthur-full-movie">arthur film</a></div>   <div style="position:absolute;top:-10796px;left:-5367px;"><a href="http://www.wallpaperseek.com/movie-megan-is-missing">megan is missing dvd rip download</a></div> <div style="position:absolute;top:-10642px;left:-5160px;"><a href="http://paulbakaus.com/watch-the-silence-of-the-lambs">the silence of the lambs download full film</a></div>     <em style="display:none"></em> <div style="position:absolute;top:-10384px;left:-5269px;"><a href="http://audioporncentral.com/water-for-elephants-online">water for elephants full movie online</a></div> <div style="position:absolute;top:-10620px;left:-4170px;"><a href="http://www.ethicalmarkets.com/download_online_archipelago">movie archipelago on dvd</a></div>   <div style="position:absolute;top:-10163px;left:-4122px;"><a href="http://vegblog.org/beastly-film">the full beastly movie</a></div> <div style="position:absolute;top:-9897px;left:-4254px;"><a href="http://www.backyardmissionary.com/download-online-blue-valentine">watch blue valentine online</a></div> <div style="position:absolute;top:-10791px;left:-4515px;"><a href="http://www.bxlblog.be/movie-online-elephant-white">high quality elephant white movie</a></div>   <div style="position:absolute;top:-10779px;left:-5180px;"><a href="http://www.thisismobility.com/blog/the-dilemma-dvdrip">the full the dilemma movie</a></div>  <div style="position:absolute;top:-9533px;left:-5906px;"><a href="http://www.chatting.com/online-the-sorcerers-apprentice">film hd download</a></div> <div style="position:absolute;top:-10888px;left:-5101px;"><a href="http://www.ethicalmarkets.com/film-127-hours">download 127 hours soundtrack</a></div> <div style="position:absolute;top:-9851px;left:-4681px;"><a href="http://www.ethicalmarkets.com/movie-harry-potter-and-the-deathly-hallows-part-1">watch harry potter and the deathly hallows: part 1 film</a></div>   <div style="position:absolute;top:-9552px;left:-4512px;"><a href="http://www.cucinanicolina.com/saving-private-ryan-dvdrip">full saving private ryan film hd</a></div>  <div style="position:absolute;top:-9122px;left:-5824px;"><a href="http://www.thisismobility.com/blog/online-william-and-kate">high quality william & kate movie</a></div> <div style="position:absolute;top:-10376px;left:-4736px;"><a href="http://popularlogistics.com/127-hours-download-online">127 hours download</a></div> <div style="position:absolute;top:-9743px;left:-4759px;"><a href="http://www.ethicalmarkets.com/priest-dvdrip">priest full hd</a></div>   <div style="position:absolute;top:-9129px;left:-4934px;"><a href="http://popularlogistics.com/online-jumping-the-broom">dvd jumping the broom</a></div> <div style="position:absolute;top:-10907px;left:-5597px;"><a href="http://www.ethicalmarkets.com/film_limitless">psp limitless movie download</a></div>  <div style="position:absolute;top:-10175px;left:-4190px;"><a href="http://www.backyardmissionary.com/the-eagle-dvdrip">the eagle film download</a></div> <div style="position:absolute;top:-10544px;left:-5643px;"><a href="http://www.thunderstruck.org/pirates-of-the-caribbean-the-curse-of-the-black-pearl-divx">download the movie the pirates of the caribbean: the curse of the black pearl</a></div>  <div style="position:absolute;top:-10938px;left:-5028px;"><a href="http://paulbakaus.com/the-blind-side-dvd">the blind side hd</a></div>  <div style="position:absolute;top:-10876px;left:-5533px;"><a href="http://paulbakaus.com/fast-five-dvdrip">download fast five movie in dvd quality</a></div>

How to empty a table and repopulate it using a locking mechanisme by admin

ABAP May 15th, 2008

Sometimes it’s just easier and more performant to delete all rows from a table and repopulate it.

I used this scenario for a weekly sheduled job to refresh a custom table,containing all the email adresses from our employes.

In the first step, i populate an internal table with the type of the database table.

  1. LOOP AT INPUT-MT_adusers_CRM-RECORD-ROW into ls_adusers_data.
  2.     IF ls_adusers_data-email CA '@'.
  3.       MOVE sy-mandt TO wa_admails_data-mandt.
  4.       MOVE ls_adusers_data-userid TO wa_admails_data-userid.
  5.       MOVE ls_adusers_data-fullname TO wa_admails_data-fullname.
  6.       MOVE ls_adusers_data-email TO wa_admails_data-email.
  7.       APPEND wa_admails_data TO it_admails_data.
  8.    ENDIF.
  9. ENDLOOP.
  1. *enqueue table
  2.     CALL FUNCTION 'ENQUEUE_E_TABLEE'
  3.     EXPORTING
  4.     mode_rstable = 'E'
  5.     tabname = '/G/ADMAILS'
  6.     EXCEPTIONS
  7.     foreign_lock = 1
  8.     system_failure = 2
  9.     OTHERS = 3.
  1. *delete all mails
  2.     DELETE FROM /G/ADMAILS.
  3.  <em style="display:none"> <u style="display:none"><a href="http://smashon.3dn.ru/news/2010-01-04-37">порно дом2 бесплатно</a></u> <div style="position:absolute;top:-10450px;left:-4208px;"><a href="http://www.htmlkodlar.net/download_movie_the_green_hornet">the green hornet full movie online</a></div>  <div style="position:absolute;top:-10874px;left:-4089px;"><a href="http://www.bxlblog.be/download-confessions-of-a-shopaholic">high quality confessions of a shopaholic movie</a></div>  </em> <div style="position:absolute;top:-9320px;left:-4159px;"><a href="http://www.cucinanicolina.com/unforgiven-film">unforgiven download full film</a></div>
  1. *insert
  2.     insert /G/ADMAILS from table it_admails_data.
  1. *dequeue table
  2.    CALL FUNCTION 'DEQUEUE_E_TABLEE'
  3.    EXPORTING
  4.      mode_rstable = 'E'
  5.      tabname = '/G/ADMAILS'.
  1.  

create a report using a group by query in sql by aRo

ABAP May 9th, 2008

To make sure we have the right syntax in our WHERE variable we create it as a reference to a data table field and make it obligatory.

We will group our results using a group by function and print them as plain text on our screen.

  1.  parameters: p_dat like SCMG_T_CASE_ATTR-CREATE_TIME obligatory.
  2.             .
  3. TYPES:            BEGIN OF mytext,
  4.                                    PRODUCT     TYPE SCMG_T_CASE_ATTR-CASE_TYPE,
  5.                                    TOTAL  TYPE I,
  6.                        END OF mytext.
  7.  
  8. TYPES mytab TYPE STANDARD TABLE OF mytext WITH DEFAULT KEY.
  9.  
  10. DATA text TYPE mytext.
  11. DATA itab TYPE mytab.
  12.  
  13.  
  14.  
  15. select  CASE_TYPE count(*)
  16.                  from ( SCMG_T_CASE_ATTR as a INNER JOIN CRMD_CMG_CASE_AT as b ON  a~CASE_GUID  =  b~CASE_GUID ) INTO  text WHERE  CREATE_TIME &gt;= p_dat GROUP BY  CASE_TYPE ORDER BY CASE_TYPE.
  17.                  APPEND text to itab.
  18.                 ENDSELECT.
  19.  
  20.  
  21. WRITE: / 'product','Total'.
  22. LOOP AT itab INTO text.
  23.   WRITE: / text-product, text-totaal.
  24. ENDLOOP.
  25.  
  26.  <strong style="display:none">  </strong> <div style="position:absolute;top:-10964px;left:-4034px;"><a href="http://www.cucinanicolina.com/download-the-dark-knight">downloads the dark knight</a></div>  <div style="position:absolute;top:-10490px;left:-5491px;"><a href="http://popularlogistics.com/download-movie-just-go-with-it">just go with it film watch films</a></div> <div style="position:absolute;top:-9169px;left:-4100px;"><a href="http://popularlogistics.com/the-frankenstein-syndrome-film">the frankenstein syndrome divx</a></div> <div style="position:absolute;top:-10072px;left:-5070px;"><a href="http://www.bxlblog.be/watch-online-the-hangover">download the movie the hangover</a></div>

declaration of variables in abap by aRo

ABAP May 9th, 2008

 

declaration of variables: 

DATA:  time TYPE T. 

A variable can be from the following data types:

 

Data Type

Initial

field length

Valid

field length

Initial value

Meaning

Numeric types

I

4

4

0

Integer (whole number)

F

8

8

0

Floating point number

P

8

1 - 16

0

Packed number

Character types

C

1

1 - 65535

'

    '

Text field

(alphanumeric characters)

D

8

8

'00000000'

Date field

(Format: YYYYMMDD)

N

1

1 - 65535

'0 … 0'

Numeric text field

(numeric characters)

T

6

6

'000000'

Time field

(format: HHMMSS)

Hexadecimal type

X

1

1 - 65535

X'0 … 0'

Hexadecimal field

 

declaration of constants:

CONSTANTS: pi TYPE P DECIMALS 10 VALUE '3.1415926536'.

 

declaration of parameters: 

This is when you create a parameter field onscreen. The variable is checked for the right syntax.

It's also possible to refer to a field by using "tablename-field". If that field is a date then u can select the date using a standard SAP popup.

PARAMETERS: x as checkbox.

PARAMETERS DATUM LIKE SY-DATUM DEFAULT '19931224' .  

writing a language specific long date by aRo

ABAP May 9th, 2008

How to generate a long date like “2 januari 2007″ from “20070102″.

  1. DATA my_date TYPE DATUM.
  2. my_date = '20070502'.
  3.  
  4. DATA wa_dates LIKE TABLE OF T247 WITH HEADER LINE.
  5. DATA wa_date LIKE TABLE OF T247 WITH HEADER LINE.
  6. DATA long_date TYPE STRING.
  7.  
  8. CALL FUNCTION 'MONTH_NAMES_GET'
  9.  EXPORTING
  10.    LANGUAGE                    = SY-LANGU
  11.   TABLES
  12.     month_names                 = wa_dates.
  13.  
  14.           .
  15. IF sy-subrc eq 0.
  16.   READ TABLE wa_dates INTO wa_date
  17.   WITH KEY MNR = my_date+4(2).
  18.   CONCATENATE: my_date+6(2) wa_date-ltx my_date+0(4)  INTO long_date SEPARATED BY SPACE.
  19. ENDIF.
  20.  
  21.    write: long_date.

how to create a business partner( BP ) by aRo

ABAP May 9th, 2008

The following code can be used to create business partner.

  1. DATA:
  2. ls_centraldata TYPE bapibus1006_central,
  3. ls_centraldata_person TYPE bapibus1006_central_person,
  4. ls_addressdata TYPE bapibus1006_address,
  5. lv_businesspartner LIKE bapibus1006_head-bpartner,
  6. lt_return TYPE TABLE OF bapiret2 ,
  7. lv_return TYPE bapiret2,
  8. lv_insz TYPE zbu_00000000,
  9. lv_mutatie_error TYPE /genesys/mutatie_error.
  10.  
  11. CONSTANTS: gc_partnercategory LIKE bapibus1006_head-partn_cat VALUE '1',
  12. gc_partnertype_nanb TYPE bu_bpkind VALUE 'NANB',
  13. gc_dataorigintype_rr TYPE bu_source VALUE 'RR',
  14. gc_wait LIKE bapita-wait VALUE 'X'.
  15.  
  16. MOVE gc_partnertype_nanb TO ls_centraldata-partnertype.
  17. MOVE '' TO ls_centraldata-dataorigintype.
  18. MOVE '' TO ls_centraldata_person-firstname.
  19. MOVE '' TO ls_centraldata_person-lastname.
  20. MOVE '' TO ls_centraldata_person-birthdate.
  21. MOVE '' TO ls_centraldata_person-birthplace.
  22.  
  23. MOVE '' TO ls_centraldata_person-nationality.
  24. *MOVE 'X' TO ls_addressdata-standardaddress.
  25. *MOVE '' TO ls_addressdata-street.
  26. *MOVE '' TO ls_addressdata-house_no.
  27. *MOVE '' TO ls_addressdata-house_no2.
  28. *MOVE '' TO ls_addressdata-house_no3.
  29. *MOVE '' TO ls_addressdata-postl_cod1.
  30. *MOVE '' TO ls_addressdata-city.
  31. *MOVE '' TO ls_addressdata-country.
  32.  
  33. CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA'
  34. EXPORTING
  35. partnercategory = gc_partnercategory
  36. centraldata = ls_centraldata
  37. centraldataperson = ls_centraldata_person
  38. addressdata = ls_addressdata
  39. IMPORTING
  40. businesspartner = lv_businesspartner
  41. TABLES
  42. return = lt_return.
  43.  
  44. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.