Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

user exit

Former Member
0 Kudos

hi all

can any one send the code for the following logic in the user exit.

1. If SAP transaction is equal to ’VA01, VA02, VA21, VA22’ then EXIT (Exit function only).

2. If Material Type is not ZKMT, then EXIT (Exit function only).

3. Check if Sales Order Number and Line Item exist, if not, Display an Error Message “Sales Order Number and Line Item Number are required”, then EXIT. End the program, the transactions is not allowed.

4. If Sales Order Cost exist in SAP Table KEKO, then EXIT. Use the following parameters:

4.1. Reference Object = “k”

4.2. Costing Type = ‘17’

4.3. Costing Status = “VO”

4.4. Sales Order Number

4.5. Line Item Number

4.6. Material

4.7. Receiving Plant

5. If Sales Order Cost exist in SAP Table EBEW for any other plant, copy that cost to the Receiving Plant and EXIT. Use the following parameters:

5.1. From:

5.1.1. Sales Order Number

5.1.2. Line Item Number

5.1.3. Material

5.1.4. Special Stock = “f”

5.2. Data to be copied:

5.2.1. Standard Cost = EBEW-STPRS

5.2.2. Price Unit = EBEW-PEINH

5.3. Pass copied Data

5.4. Exit Function

6. If there is not cost in table EBEW, get the Sales Order Standard Cost number from SAP Tables KEKO and KEPH from any other plant. Use the following parameters:

6.1. Read table KEKO

6.1.1. Reference Object = “g”

6.1.2. Costing Type = ‘18’

6.1.3. Sales Order Number

6.1.4. Line Item Number

6.1.5. Material

6.2. Get the Product Cost Estimate Number = KEKO-KALNR

6.3. Get the costing lot size = KEKO-LOSAU and populate EBEW-PEINH

6.4. If not record exist, Display the message “There is not Sales Order Cost for &material in &plant for & SalesOrder and &LineItem”, then EXIT the Program, transaction is not allowed.

6.5. Read table KEPH

6.5.1. Reference Object = “B”

6.5.2. Costing Type = ‘18’

6.5.3. Product Cost Estimate Number = KEKO-KALNR

6.5.4. Costing Version ‘ “01” (Zero and one)

6.6. Get the Cost Components Value

6.6.1. KEPH-KST001 to KEPH-KST040 (40 values)

6.7. Get Cost Components Value Index from table TCKH3. Use the following parameters:

6.7.1. Structure (ELEHK) = “LS”

6.7.2. Get Data : Store the value in field Full Cost (EL_HV) for all records in the table. These values will be used as index in the formula to calculate the Total Standard Cost.

6.8. Calculate Sales Order Cost Estimate to populate filed EBEW-STPRS.

6.8.1. Add value stored in the fields KEPH-KSTnnn. Find nnn in table TCKH3 where nnn equals EL_HV.

6.8.2. If total is equal to ZERO display the message “Standard Cost is ZERO, transaction is not allowed”. Exit the Program.

6.8.3. Return the Values:

6.8.3.1. Standard Cost (EBEW-STPRS)

6.8.3.2. Price Unit (EBEW-PEINH)

3 REPLIES 3

Former Member
0 Kudos

Please send us the reason to code... i.e., purpose of the requirement.. so that the code wud be robust in nature.

Also the user exit number to analyze the import and export parameters.

Message was edited by: Sandeep Josyula

0 Kudos

HI SANDEEP THE EXIT IS

EXIT_SAPLCK36_001 INCLUDE IS ZXCKAU04

Former Member
0 Kudos

Try this program which reports the no of userexits and badi's for a particular transaction or for a particular program.

&----


*& Report Z_TO_FIND_BADI_EXITS *

*& *

&----


*& *

*& *

&----


REPORT Z_TO_FIND_BADI_EXITS.

TABLES : TSTC,

TADIR,

MODSAPT,

MODACT,

TRDIR,

TFDIR,

ENLFDIR,

SXS_ATTRT ,

TSTCT.

DATA : JTAB LIKE TADIR OCCURS 0 WITH HEADER LINE.

DATA : FIELD1(30).

DATA : V_DEVCLASS LIKE TADIR-DEVCLASS.

PARAMETERS : P_TCODE LIKE TSTC-TCODE,

P_PGMNA LIKE TSTC-PGMNA .

DATA wa_tadir type tadir.

START-OF-SELECTION.

IF NOT P_TCODE IS INITIAL.

SELECT SINGLE * FROM TSTC WHERE TCODE EQ P_TCODE.

ELSEIF NOT P_PGMNA IS INITIAL.

TSTC-PGMNA = P_PGMNA.

ENDIF.

IF SY-SUBRC EQ 0.

SELECT SINGLE * FROM TADIR

WHERE PGMID = 'R3TR'

AND OBJECT = 'PROG'

AND OBJ_NAME = TSTC-PGMNA.

MOVE : TADIR-DEVCLASS TO V_DEVCLASS.

IF SY-SUBRC NE 0.

SELECT SINGLE * FROM TRDIR

WHERE NAME = TSTC-PGMNA.

IF TRDIR-SUBC EQ 'F'.

SELECT SINGLE * FROM TFDIR

WHERE PNAME = TSTC-PGMNA.

SELECT SINGLE * FROM ENLFDIR

WHERE FUNCNAME = TFDIR-FUNCNAME.

SELECT SINGLE * FROM TADIR

WHERE PGMID = 'R3TR'

AND OBJECT = 'FUGR'

AND OBJ_NAME EQ ENLFDIR-AREA.

MOVE : TADIR-DEVCLASS TO V_DEVCLASS.

ENDIF.

ENDIF.

SELECT * FROM TADIR INTO TABLE JTAB

WHERE PGMID = 'R3TR'

AND OBJECT in ('SMOD', 'SXSD')

AND DEVCLASS = V_DEVCLASS.

SELECT SINGLE * FROM TSTCT

WHERE SPRSL EQ SY-LANGU

AND TCODE EQ P_TCODE.

FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.

WRITE:/(19) 'Transaction Code - ',

20(20) P_TCODE,

45(50) TSTCT-TTEXT.

SKIP.

IF NOT JTAB[] IS INITIAL.

WRITE:/(105) SY-ULINE.

FORMAT COLOR COL_HEADING INTENSIFIED ON.

  • Sorting the internal Table

sort jtab by OBJECT.

data : wf_txt(60) type c,

wf_smod type i ,

wf_badi type i ,

wf_object2(30) type C.

clear : wf_smod, wf_badi , wf_object2.

  • Get the total SMOD.

LOOP AT JTAB into wa_tadir.

at first.

FORMAT COLOR COL_HEADING INTENSIFIED ON.

WRITE:/1 SY-VLINE,

2 'Enhancement/ Business Add-in',

41 SY-VLINE ,

42 'Description',

105 SY-VLINE.

WRITE:/(105) SY-ULINE.

endat.

clear wf_txt.

at new object.

if wa_tadir-object = 'SMOD'.

wf_object2 = 'Enhancement' .

elseif wa_tadir-object = 'SXSD'.

wf_object2 = ' Business Add-in'.

endif.

FORMAT COLOR COL_GROUP INTENSIFIED ON.

WRITE:/1 SY-VLINE,

2 wf_object2,

105 SY-VLINE.

endat.

case wa_tadir-object.

when 'SMOD'.

wf_smod = wf_smod + 1.

SELECT SINGLE MODTEXT into wf_txt

FROM MODSAPT

WHERE SPRSL = SY-LANGU

AND NAME = wa_tadir-OBJ_NAME.

FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

when 'SXSD'.

  • For BADis

wf_badi = wf_badi + 1 .

select single TEXT into wf_txt

from SXS_ATTRT

where sprsl = sy-langu

and EXIT_NAME = wa_tadir-OBJ_NAME.

FORMAT COLOR COL_NORMAL INTENSIFIED ON.

endcase.

WRITE:/1 SY-VLINE,

2 wa_tadir-OBJ_NAME hotspot on,

41 SY-VLINE ,

42 wf_txt,

105 SY-VLINE.

AT END OF object.

write : /(105) sy-ULINE.

ENDAT.

ENDLOOP.

WRITE:/(105) SY-ULINE.

SKIP.

FORMAT COLOR COL_TOTAL INTENSIFIED ON.

WRITE:/ 'No.of Exits:' , wf_smod.

WRITE:/ 'No.of BADis:' , wf_badi.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(105) 'No userexits or BADis exist'.

ENDIF.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(105) 'Transaction does not exist'.

ENDIF.

AT LINE-SELECTION.

data : wf_object type tadir-object.

clear wf_object.

GET CURSOR FIELD FIELD1.

CHECK FIELD1(8) EQ 'WA_TADIR'.

read table jtab with key obj_name = sy-lisel+1(20).

move jtab-object to wf_object.

case wf_object.

when 'SMOD'.

SET PARAMETER ID 'MON' FIELD SY-LISEL+1(10).

CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

when 'SXSD'.

SET PARAMETER ID 'EXN' FIELD SY-LISEL+1(20).

CALL TRANSACTION 'SE18' AND SKIP FIRST SCREEN.

endcase.

Cheers

Badri.