on 07-04-2009 12:46 AM
everything that a programmer should not do!!!
In this thread there is little collection of various set of bizarre ABAP statements that I have captured around in the projects.
Now I would like to share this stuff with you, just to having fun.
In some cases you will find also the link to the screenshot as the evidence that I'm not under the influence of the alcohol or drugs.
I think that some pieces of ABAPs are very funny!!!
E.g. this one:
[A Terrible IF|http://picasaweb.google.com/lh/photo/3pOmX1_raCMR6NEhKFBa4w?feat=directlink]
Obviously all of you are invited to keep this thread updated.
Andrea
..Cry for missing kernel patches...
[http://picasaweb.google.com/lh/photo/Potb6gpKOhS4XmJRIr44bA?feat=directlink]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
...Try to translate from Italian to English..
[http://picasaweb.google.com/lh/photo/JtoJws1gMMC8ThZUeJ_Ung?feat=directlink]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No comment....
[http://picasaweb.google.com/lh/photo/ijfzuu1Ay4k4BMQQk3i3Ow?feat=directlink]
Edited by: Andrea Olivieri on Oct 27, 2009 6:37 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
...
Edited by: Matt on Jul 13, 2009 5:35 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This custom code was found on SAP ECC system...
Read the same internal table more times with the same selection!
[http://delirihitech.blogspot.com/2009/02/worst-abap-code-ever-seen.html]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I fancy my chances with this baby. Directly updating an SAP table on a record by record basis, and table-scanning each time.
With 7 million records in EBAN this literally ran for days. After I rewrote it with a BAPI it ran through in under 20 minutes.
SELECT a~banfn a~bnfpo a~matnr a~bsart a~loekz a~ernam a~badat
a~erdat a~werks a~lgort a~flief a~infnr a~ebeln a~ebakz
INTO TABLE i_data
FROM eban AS a INNER JOIN ekko AS b ON a~ebeln = b~ebeln
INNER JOIN eket AS c ON a~banfn = c~banfn
WHERE ( a~bsart EQ 'NB' OR a~bsart EQ 'ZNB' )
AND a~loekz EQ ''
AND a~statu EQ 'B'
AND a~ebakz EQ ''
AND a~flief NE 'U5005'
AND b~bsart EQ 'LP'.
LOOP AT i_data.
UPDATE eban SET ebakz = 'X'
WHERE ebeln = i_data-ebeln.
COMMIT WORK AND WAIT.
ENDLOOP
I don't understand...
[http://picasaweb.google.com/lh/photo/am5jSIsLbfaQg_qJvro58g?feat=directlink]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An endless delay after COMMIT&WAIT statement...
[http://picasaweb.google.com/lh/photo/Sa0RIenJgawIX08yRvlksw?feat=directlink]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works but it's so funny...
(...)
*&---------------------------------------------------------------------*
*& Form DELETE-TB_BSEG
*&---------------------------------------------------------------------*
FORM DELETE-TB_BSEG.
LOOP AT TB_BSEG.
DELETE TB_BSEG.
ENDLOOP.
ENDFORM. " DELETE-TB_BSEG
(...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is terrible...
[http://picasaweb.google.com/lh/photo/SG7dQDiSns9DfGv-SZYeeQ?feat=directlink]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Programs of the past...
[http://picasaweb.google.com/lh/photo/k2v5jgPrk7Vf9LItCfKNmQ?feat=directlink]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
...Even a Form Routine it was created!
(...)
END-OF-SELECTION.
PERFORM STATISTIC.
*&---------------------------------------------------------------------*
*& Form STATISTIC
*&---------------------------------------------------------------------*
FORM STATISTIC.
WRITE:/'end of processing'.
ENDFORM. " STATISTIC
(...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nested Statements...
[http://picasaweb.google.com/lh/photo/YM-pQDtnbGwfEFHiwoTmzQ?feat=directlink]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This routine that checks the amount is active! I swear it!
(...)
* Escludo la condizione se : - Posizione senza determinazione prezzo
* - Imponibile IVA = 0
FORM KOBED_904.
SY-SUBRC = 4.
IF KOMP-KPOSN NE 0.
CHECK KOMP-PRSFD = 'X'. "Pos. determin. prezzo
* check komk-waerk ne 'EUR '. "Valuta non EURO
CHECK KOMP-MWSBP EQ 0 OR "Imponibile IVA = 0
KOMP-MWSBP EQ 2500. "Imponibile IVA = 2500
ENDIF.
SY-SUBRC = 0.
ENDFORM.
(...)
Edited by: Andrea Olivieri on Jul 4, 2009 2:28 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Take a look also to the customer communication language determination in order to open the SAPscript form ....
(...)
IF vbrk-kunag EQ '0004014920'. " <!!!!!!!!!!!!!!!!!!!!!!!!
STOP. "<AAAAARGHHHHHH
ENDIF.
* if t005-landa eq '005'.
* stop.
* endif.
**** BRD 24.02.2003: per bloccare stampa T-Invoice per ITALIA
* cacmau@xxx forzatura della lingua I 18/11/98
* NAST-SPRAS = 'I'.
* cacmau@xxx 18/11/98
*** XXX 11.12.2002
nast-spras = 'E'. " <!!!!!!!!!!!!!!!!!!!!!!!!!
*** XXX 11.12.2002
CALL FUNCTION 'OPEN_FORM'
EXPORTING
form = tnapr-fonam
language = nast-spras
options = itcpo
archive_index = toa_dara
archive_params = arc_params
device = xdevice
dialog = ' '
EXCEPTIONS
OTHERS = 1.
(...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Language management...and conversion exit
(...)
*&---------------------------------------------------------------------*
*& Form TROVA_SPRAS
*&---------------------------------------------------------------------*
form trova_spras.
move 'gb' to tab-spras.
if kna1-land1 eq 'IT'. move 'i' to tab-spras. endif.
if kna1-land1 eq 'GB'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'AT'. move 'd' to tab-spras. endif.
if kna1-land1 eq 'BE'. move 'f' to tab-spras. endif.
if kna1-land1 eq 'CH'. move 'd' to tab-spras. endif.
if kna1-land1 eq 'CZ'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'DE'. move 'd' to tab-spras. endif.
if kna1-land1 eq 'DK'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'ES'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'FR'. move 'f' to tab-spras. endif.
if kna1-land1 eq 'GB'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'HU'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'IS'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'MXu2018. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'NL'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'NO'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'PL'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'RU'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'SE'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'SK'. move 'd' to tab-spras. endif.
if kna1-land1 eq 'TR'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'US'. move 'gb' to tab-spras. endif.
if kna1-land1 eq 'ZA'. move 'gb' to tab-spras. endif.
(...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is a certification test ...
[http://picasaweb.google.com/lh/photo/OujhPGyJCCx-aXvpxeXeOA?feat=directlink]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
(...)
*&---------------------------------------------------------------------*
*& Form SISTEMA-VERSIONI
*&---------------------------------------------------------------------*
FORM SISTEMA-VERSIONI.
SELECT SINGLE * FROM TVARV WHERE NAME = 'EB0185_YOUR_DOCS_VERS09'.
IF SY-SUBRC = 0.
MOVE TVARV-LOW TO TB-VARV-LOW-10.
ELSE.
MOVE SPACE TO TB-VARV-LOW-10.
ENDIF.
SELECT SINGLE * FROM TVARV WHERE NAME = 'EB0185_YOUR_DOCS_VERS08'.
IF SY-SUBRC = 0.
MOVE TVARV-LOW TO TB-VARV-LOW-09.
ELSE.
MOVE SPACE TO TB-VARV-LOW-09.
ENDIF.
SELECT SINGLE * FROM TVARV WHERE NAME = 'EB0185_YOUR_DOCS_VERS07'.
IF SY-SUBRC = 0.
MOVE TVARV-LOW TO TB-VARV-LOW-08.
ELSE.
MOVE SPACE TO TB-VARV-LOW-08.
ENDIF.
SELECT SINGLE * FROM TVARV WHERE NAME = 'EB0185_YOUR_DOCS_VERS06'.
IF SY-SUBRC = 0.
MOVE TVARV-LOW TO TB-VARV-LOW-07.
ELSE.
MOVE SPACE TO TB-VARV-LOW-07.
ENDIF.
SELECT SINGLE * FROM TVARV WHERE NAME = 'EB0185_YOUR_DOCS_VERS05'.
IF SY-SUBRC = 0.
MOVE TVARV-LOW TO TB-VARV-LOW-06.
ELSE.
MOVE SPACE TO TB-VARV-LOW-06.
ENDIF.
SELECT SINGLE * FROM TVARV WHERE NAME = 'EB0185_YOUR_DOCS_VERS04'.
IF SY-SUBRC = 0.
MOVE TVARV-LOW TO TB-VARV-LOW-05.
ELSE.
MOVE SPACE TO TB-VARV-LOW-05.
ENDIF.
SELECT SINGLE * FROM TVARV WHERE NAME = 'EB0185_YOUR_DOCS_VERS03'.
IF SY-SUBRC = 0.
MOVE TVARV-LOW TO TB-VARV-LOW-04.
ELSE.
MOVE SPACE TO TB-VARV-LOW-04.
ENDIF.
SELECT SINGLE * FROM TVARV WHERE NAME = 'EB0185_YOUR_DOCS_VERS02'.
IF SY-SUBRC = 0.
MOVE TVARV-LOW TO TB-VARV-LOW-03.
ELSE.
MOVE SPACE TO TB-VARV-LOW-03.
ENDIF.
ENDFORM. " SISTEMA-VERSIONI
(...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How to dynamically assign the path of a file ...
(...)
INITIALIZATION.
CASE SY-SYSID.
WHEN 'BI2'. P_DIR = '/usr/svl/wrk'.
WHEN 'BI3'. P_DIR = '/usr/test/wrk'.
WHEN 'BI4'. P_DIR = '/usr/prod/wrk'.
ENDCASE.
(...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
(...)
SELECT * FROM t9mmm WHERE matnr = t_mbew- matnr
AND bwkey = t_mbew-bwkey
AND lfgja = annop
AND lfmon = '12'.
IF sy-subrc NE 0. "<----!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WRITE: / ' Mat. non trovato su t9mmm ',
t_mbew-matnr, annop , '12'.
CONTINUE.
ENDIF.
MOVE t9mmm-lbkum TO t_lifo-vjkum.
ENDSELECT.
(...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.