ABAP Code To Authenticate Users
Hi,
How can I code a ABAP program/function which will authenticate a user based only on their user id? Do not want to use their password.
I want the entire authentication process to happen in the ABAP code.
Any ideas?
Thanks,
Audrey
Hi,
To check the authorization of the user of an ABAP program, use the AUTHORITY-CHECK statement:
AUTHORITY-CHECK OBJECT '<object>'
ID '<name1>' FIELD <f1>
ID '<name2>' FIELD <f2>
ID '<name10>' FIELD <f10>.
<object> is the name of the object that you want to check. You must list the names (<name1>, <name2> ...) of all authorization fields that occur in <object>. You can enter the values <f 1 >, <f 2 >.... for which the authorization is to be checked either as variables or as literals. The AUTHORITY-CHECK statement checks the users profile for the listed object, to see whether the user has authorization for all values of <f>. Then, and only then, is SY-SUBRC set to 0. You can avoid checking a field by replacing FIELD <f> with DUMMY. You can only evaluate the result of the authorization check by checking the contents of SY-SUBRC. For a list of the possible return values and further information, see the keyword documentation for the AUTHORITY-CHECK statement. For further general information about the SAP authorization concept, refer to Users and Authorizations.
There is an authorization object called F_SPFLI. It contains the fields ACTVT, NAME, and CITY.
SELECT * FROM SPFLI.
AUTHORITY-CHECK OBJECT 'F_SPFLI'
ID 'ACTVT' FIELD '02'
ID 'NAME' FIELD SPFLI-CARRID
ID 'CITY' DUMMY.
IF SY-SUBRC NE 0. EXIT. ENDIF.
ENDSELECT.
If the user has the following authorizations for F_SPFLI:
ACTVT 01-03, NAME AA-LH, CITY none,
and the value of SPFLI-CARRID is not between "AA" and "LH", the authorization check terminates the SELECT loop.
Hope it helps u.
Thanks&Regards,
Ruthra.R
Similar Messages
-
ABAP code tuning in BW extractor
Hi All,
I am enhancing a purchasing BW extractor to get Pricing details for a PO and its Item .
The ABAP code in the user exit is similar to this:
select SINGLE knumh from A016 INTO T_KNUMH1
WHERE EVRTN = EKPO-KONNR
AND EVRTP = EKPO-KTPNR
AND ( DATAB LE EKPO-AEDAT AND
DATBI GE EKPO-AEDAT ).
The problem here is A016 is a pooled table and when i check in SM50 while this user exit is running the code hangs in KAPOL ( Table pool) for a long time.
We are having long times during data loads. Does anyone know how to tune this code or any other tables from which i can take pricing related to purchasing.
Regards
satishif you look for the check tables for KONNR and KTPNR, it is EKKO and EKPO itself. that means, there shud be an entry in EKKO with your required KONNR.
so why dont you pick the knumv from EKKO itself ?
select knumv from ekko where ebeln = ekpo-konnr.
now, do whatever further selections you want to do, using this KNUMV.
knumv = a016-knumh.
no need to do select from a016 at all, as we already have KNUMV. -
How To Code the I_CALLBACK_USER_COMMAND = 'USER' in HR-ABAP
Dear Friends,
How to code the I_CALLBACK_USER_COMMAND = 'USER' in Reuse_Alv_Grid_Display in HR-ABAPThis is one method of programming the user_commend
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_structure_name = 'I_DATA'
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_sort = gt_sort[]
i_save = 'A'
is_variant = es_variant
it_events = gt_events[]
is_print = gs_print
tables
t_outtab = i_data
exceptions
program_error = 1
others = 2.
*& USER_COMMAND
*& This form is called through Function 'REUSE_ALV_GRID_DISPLAY'.
*& If you are in detailed mode then transaction PA20
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&IC1'.
check rs_selfield-sel_tab_field = 'I_DATA-PERNR'.
read table i_data index rs_selfield-tabindex.
set parameter id 'PER' field i_data-pernr.
call transaction 'PA20'.
when others.
endcase.
endform. "user_command -
Sample ABAP code for userexits, and calling bapi's
Hi,
Can someone please send me sample ABAP code
1) to do extractor enhancement using user exit.
2) ABAP program to call BAPI to read live cache order series data in SNP and write to Idocs through some ports.
3) ABAP routine to generate file name (based on date/country)in the infopackage to upload flatfiles.
Thank you very much in advance and appreciate any help.
Regards
Prasadhai ,
check this code...
*& Tables
tables : tstc, "SAP Transaction Codes
tadir, "Directory of Repository Objects
modsapt, "SAP Enhancements - Short Texts
modact, "Modifications
trdir, "System table TRDIR
tfdir, "Function Module
enlfdir, "Additional Attributes for Function Modules
tstct. "Transaction Code Texts
*& Variables
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
*& Selection Screen Parameters
selection-screen begin of block a01 with frame title text-001.
selection-screen skip.
parameters : p_tcode like tstc-tcode obligatory.
selection-screen skip.
selection-screen end of block a01.
*& Start of main program
start-of-selection.
Validate Transaction Code
select single * from tstc
where tcode eq p_tcode.
Find Repository Objects for transaction code
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 = enlfdir-area.
move : tadir-devclass to v_devclass.
endif.
endif.
Find SAP Modifactions
select * from tadir
into table jtab
where pgmid = 'R3TR'
and object = 'SMOD'
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:/(95) sy-uline.
format color col_heading intensified on.
write:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
write:/(95) sy-uline.
loop at jtab.
select single * from modsapt
where sprsl = sy-langu and
name = jtab-obj_name.
format color col_normal intensified off.
write:/1 sy-vline,
2 jtab-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table jtab.
skip.
format color col_total intensified on.
write:/ 'No of Exits:' , sy-tfill.
else.
format color col_negative intensified on.
write:/(95) 'No User Exit exists'.
endif.
else.
format color col_negative intensified on.
write:/(95) 'Transaction Code Does Not Exist'.
endif.
Take the user to SMOD for the Exit that was selected.
at line-selection.
get cursor field field1.
check field1(4) eq 'JTAB'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen. -
Help needed in writting Customer exit - ABAP Code
Hi Friends,
I have a scenario in one of the query and need to write a customer exit for the same. Here is the scenario:
I am using one input variable XXX to get input from user which feeds value to one of the charateristic lets say "CHAR1" in query. I have one more characteristic "CHAR2" which has to get the value from the same variable XXX. This is not allowed in BI7.0 as the variable is Hierarchy Node type. It gives error that "Variable XXX is used for two different characteristics."
So i need to create one more vaiable YYY which will get the value from XXX and then YYY will feed value to CHAR2. I would appreciate if some one could tell me step by step how to write customer exit and give me the piece of ABAP code i need to write in my case.
Your help will be appreciated in terms of points.
Thanks,
manmitHi Arun,
1. What should CHAR2 take - Hierarchy node variable or something else ?
--> CHAR2 is a simple charateristic
2. In your scenario - why have CHAR1 and CHAR2 ? why not have the user enter values against CHAR2 ??
--> We dont want user to enter two input as the input values for both Chars are same.
3. Did you try using a replacement path variable with the CHAR2 variable taking values from Variable on CHAR1 ?
--> In BI7.0 replacement path variable only take values from Query results. So not able to do the same.
Thanks -
How to transfer data in change log table of dso to z-table using abap code
Hi can you please explain me how to transfer data in change log table of dso to z-table using abap code ,with out using Function module concept
PROGRAM NAME: ZBW_DELTA_TO_GSTAR **
report ZBW_DELTA_TO_GSTAR no standard page heading
line-size 120
line-count 75
message-id ZBW_MSG_CLS.
tables: ZGIV_DLTA_EBV_BB,
ZGIV_DLTA_EM2_BL,
ZGIV_DLTA_EM2_BK.
Selection Screen Definitions
SELECTION-SCREEN: BEGIN OF BLOCK INNER WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN: SKIP 1.
PARAMETERS: EBVBB RADIOBUTTON GROUP ROLL,
EM2BL RADIOBUTTON GROUP ROLL,
EM2BK RADIOBUTTON GROUP ROLL.
SELECTION-SCREEN: END OF BLOCK INNER.
Data: WS_UPDATE_FLAG Type C,
UCounter(9) Type N,
ICounter(9) Type N.
DATA: T_ZGIV_DLTA_EBV_BB Type Standard Table of ZGIV_DLTA_EBV_BB,
s_ZGIV_DLTA_EBV_BB LIKE line of T_ZGIV_DLTA_EBV_BB.
DATA: T_ZGIV_DLTA_EM2_BK Type Standard Table of ZGIV_DLTA_EM2_BK,
s_ZGIV_DLTA_EM2_BK LIKE line of T_ZGIV_DLTA_EM2_BK.
DATA: T_ZGIV_DLTA_EM2_BL Type Standard Table of ZGIV_DLTA_EM2_BL,
s_ZGIV_DLTA_EM2_BL LIKE line of T_ZGIV_DLTA_EM2_BL.
Standard Internal Tables - Describe usage.
data: begin of i_AEPSD_O0140 occurs 0.
include structure /BIC/AEPSD_O0140.
data: end of i_AEPSD_O0140.
data: begin of i_AEPSD_O0240 occurs 0.
include structure /BIC/AEPSD_O0240.
data: end of i_AEPSD_O0240.
data: begin of i_AEPSD_O0340 occurs 0.
include structure /BIC/AEPSD_O0340.
data: end of i_AEPSD_O0340.
data: begin of i_GIV_DLTA_EBV_BB occurs 0.
include structure ZGIV_DLTA_EBV_BB.
data: end of i_GIV_DLTA_EBV_BB.
data: begin of i_GIV_DLTA_EM2_BK occurs 0.
include structure ZGIV_DLTA_EM2_BK.
data: end of i_GIV_DLTA_EM2_BK.
data: begin of i_GIV_DLTA_EM2_BL occurs 0.
include structure ZGIV_DLTA_EM2_BL.
data: end of i_GIV_DLTA_EM2_BL.
Miscellaneous Program Variables and Constants.
TOP-OF-PAGE
top-of-page.
START-OF-SELECTION
start-of-selection.
Clear: i_GIV_DLTA_EBV_BB,
i_GIV_DLTA_EM2_BK,
i_GIV_DLTA_EM2_BL,
UCounter, ICounter.
IF EBVBB = 'X'.
PERFORM 100_EXTRACT_EBV_BB_DELTA_RECS.
ELSEIF EM2BK = 'X'.
PERFORM 100_EXTRACT_EM2_BK_DELTA_RECS.
ELSE.
PERFORM 100_EXTRACT_EM2_BL_DELTA_RECS.
ENDIF.
FORM 100_EXTRACT_EBV_BB_DELTA_RECS
FORM 100_EXTRACT_EBV_BB_DELTA_RECS.
Refresh: i_AEPSD_O0140,
i_GIV_DLTA_EBV_BB.
Clear: UCounter, ICounter, s_ZGIV_DLTA_EBV_BB .
Select * From /BIC/AEPSD_O0140
Into TABLE i_AEPSD_O0140.
IF SY-Subrc = 0.
LOOP AT i_AEPSD_O0140.
MOVE-CORRESPONDING i_AEPSD_O0140 TO s_ZGIV_DLTA_EBV_BB.
MOVE SY-DATUM to s_ZGIV_DLTA_EBV_BB-create_dt.
INSERT ZGIV_DLTA_EBV_BB FROM s_ZGIV_DLTA_EBV_BB.
IF SY-Subrc = 0.
ICounter = ICounter + 1.
ELSE.
UPDATE ZGIV_DLTA_EBV_BB FROM s_ZGIV_DLTA_EBV_BB.
IF SY-Subrc = 0.
UCounter = UCounter + 1.
ELSE.
Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "100_EXTRACT_EBV_BB_DELTA_RECS
FORM 100_EXTRACT_EM2_BK_DELTA_RECS
FORM 100_EXTRACT_EM2_BK_DELTA_RECS.
Refresh: i_AEPSD_O0240,
i_GIV_DLTA_EM2_BK.
Clear: UCounter, ICounter, s_ZGIV_DLTA_EM2_BK .
Select * From /BIC/AEPSD_O0240
Into TABLE i_AEPSD_O0240.
IF SY-Subrc = 0.
LOOP AT i_AEPSD_O0240.
MOVE-CORRESPONDING i_AEPSD_O0240 TO s_ZGIV_DLTA_EM2_BK.
MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BK-create_dt.
INSERT ZGIV_DLTA_EM2_BK FROM s_ZGIV_DLTA_EM2_BK.
IF SY-Subrc = 0.
ICounter = ICounter + 1.
ELSE.
UPDATE ZGIV_DLTA_EM2_BK FROM s_ZGIV_DLTA_EM2_BK.
IF SY-Subrc = 0.
UCounter = UCounter + 1.
ELSE.
Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "100_EXTRACT_EM2_BK_DELTA_RECS
FORM 100_EXTRACT_EM2_BL_DELTA_RECS
FORM 100_EXTRACT_EM2_BL_DELTA_RECS.
Refresh: i_AEPSD_O0340,
i_GIV_DLTA_EM2_BL.
Clear: UCounter, ICounter, s_ZGIV_DLTA_EM2_BL .
Select * From /BIC/AEPSD_O0340
Into TABLE i_AEPSD_O0340.
IF SY-Subrc = 0.
LOOP AT i_AEPSD_O0340.
MOVE-CORRESPONDING i_AEPSD_O0340 TO s_ZGIV_DLTA_EM2_BL.
MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BL-create_dt.
INSERT ZGIV_DLTA_EM2_BL FROM s_ZGIV_DLTA_EM2_BL.
IF SY-Subrc = 0.
ICounter = ICounter + 1.
ELSE.
UPDATE ZGIV_DLTA_EM2_BL FROM s_ZGIV_DLTA_EM2_BL.
IF SY-Subrc = 0.
UCounter = UCounter + 1.
ELSE.
Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "100_EXTRACT_EM2_BL_DELTA_RECS
END-OF-SELECTION
end-of-selection.
perform D1000_REPORT_DATA.
D1000_REPORT_DATA
form D1000_REPORT_DATA.
*Display the title of the program
write: /25 SY-TITLE.
skip.
Diaplay the details of the user and time
write: /1 'Executed by', 15 SY-UNAME, 30 'Date',
38 SY-DATUM, 53 'Time', 60 SY-UZEIT.
skip 2.
write: / 'Delta Records have been extracted ',
/ 'Updates : ', UCounter,
/ 'Inserts : ', ICounter.
skip.
skip 3.
write: /20 'End of the report'.
endform. "D1000_REPORT_DATA
chgeck it out this also may hep you -
OC4J Security fails to authenticate users on a 64 bit solarisx86 machine
Hi,
I am using a database login module to authenticate users. The login module I use is DBTableLoginModule. On 32 bit windows based machine, the module functions perfectly fine. When I deployed my project on a 64 bit solarisx86 machine, users are no longer able to login. On debugging the DBTableLoginModule, the authentication shows success and the commit method is return true to the OC4J security. But OC4J is redirecting to error page and I have no clue as to why it is doing so. The problem is I am not able to debug OC4J security for I have no source code for that. My question is how can i turn on debugging for OC4J Security
so I can watch out for any errors or anything that OC4J complains about so I can have better chances to overcome this problem.
Thanks
SamHi,
sounds like a OC4J bug to me (or issue at least). You may want to check
OC4J
Frank -
LKM SAP BW to Oracle (SQLLDR) generates sintax error in ABAP code.
Hi Experts,
We are installing a SAP BW KM's in ODI 11g.
Actually, we are able to make reverse ingeneering succesfully.
Now we want to use the LKM in order to extract SAP data.
The KM fails, in step Generate ABAP Code. The code is uploaded to SAP system but with sintaxis errors.
That's the beginning of the SAPAbapExecuteOpenTool_8001_7001.log.
+##################################################+
+############ Open Tool Logger ####################+
+##################################################+
+############ Upload value: 1+
+############ Execute value: 1+
+############ BASE RKM FLAG: 0+
+############ ZRFC_RUN_INSTALL: 1+
+############ Abap Function Name: ZODI_8001_7001+
+############ Sap Host Name: XXXXXXXX+
+############ Sap User Name: XXXX+
+############ Sap password: ********+
+############ Sap Client: 100+
+############ Sap language: ES+
+############ Sap system no: 00+
+############ Sap Connection Pool Name: SAP_ODI_LKM_POOL_GLOBAL+
+############ Sap Connection Pool Size: 10+
+############ Sap Function group name: ZODIBW_LKM_FGRP+
+############ File Delimiter:+
+############ File Name: ZODI_8001_7001.txt+
+############ FTP Host: XXXXXXXXX+
+############ FTP User: ftpbi+
+############ FTP Password: ********+
+############ FTP Passive Mode: 1+
+############ FTP Transfer Time out: 100000+
+############ User abap parameter names: IV_DELIMITER,CHAR1;IV_FILENAME,CHAR255;IV_USER,CHAR35;IV_PWD,CHAR35;IV_HOST,CHAR35;IV_HASHVALUE,CHAR35;IV_PATH,CHAR35;IV_REQUID_L,RSSID;IV_REQUID_H,RSSID+
+############ Abap rfc table parameters: RETURN,BAPIRETURN;ET_FILE_RETURN,BAPIRET2+
+############ Log File Name: /tmp/SAPAbapExecuteOpenTool_8001_7001.log+
+############ OpenHub Path: /tmp/+
+############ Delta Extraction First Request ID : 0+
+############ Delta Extraction Last Request ID : 0+
+############ SAP Development Class : ZODIBW_PCKG+
+############ Max Row Count :+
+############ Fetch Batch Size :+
+############ Hash Value Marker: HVM+
+############ Generated Program:+
*** ODS DSO extraction
TYPES: BEGIN OF ty_final,
+/BIC/AZOFI_UTE00_/BIC/ZFI_SOCOR+
TYPE
+/BIC/AZOFI_UTE00-/BIC/ZFI_SOCOR,+
+/BIC/AZOFI_UTE00_SOURSYSTEM+
TYPE
+/BIC/AZOFI_UTE00-SOURSYSTEM,+
END OF ty_final.
In the SAP GUI shows a sintaxis error.
Functions Module ZODI_8001_7001. line 25
The name "/BIC/AZOFI_UTE00_/BIC/ZFI_SOCOR" is longer that allowed.
+30 characters.+
Really the TYPE "/BIC/AZOFI_UTE00_/BIC/ZFI_SOCOR" has 31 characters.
The sufix "/BIC/" is the "NAMESPACE", a SAP grouping concept.
AZOFI_UTE00 is a table name.
ZFI_SOCOR is a column name.
Are this sufix correct in the APAP code?
Has anyone had that problem?
Any comment will be wellcome.
Thank's in advance.Hi Somchai,
r U able to resolve ur issue ..........i'm also struck there at the same point.
I am using shared folder for file transfer and my error message is
java.lang.RuntimeException: Error occured in open tool execute method...Error in executing ABAP program...Error in executing ABAP program...Error occurred when creating dataset\\<hostname>\bi-interface$\ZODI_11001_12001_GLOBAL.txt
Thanks.
Edited by: Drona on Mar 26, 2012 7:25 AM -
Difference between checking Objects in SU24 and in ABAP code
Hi all,
What is the difference between objects checked in SU24 and the objects checked in ABAP Code.
I think if objects are even checked to No in SU24 and they are in ABAP code then user is able is able to execute that object, is this correct?
and vice versa, if objects are checked to yes in su24 and not in the ABAP code then user wont be able to excute? is this correct
or what is the purpose of maintaing objects both in SU24 and in ABAP Code.
Thanks,
SunThis is what is known in German as a "Schwerer Geburt"... (not sure whether there is an English term which has the same meaning)...
When you searched, did you read this thread?:
F110 - S_BTCH_ADM
>
Julius Bussche wrote:
> My understanding of this confusion is ...
>
> ... SAP's development systems deem an "unknown" check to be successfull until specifiied for a check (this is different in customer systems - which leads many to believe that adding and removing check indicators from SU24 will add and remove authority-checks....),
>
> ...This problem then reproduces itself both in SU53 and ST01 once the SU22 / SU24 error has been made.
>
> ...It is one of those things which you need to know or find on your own (not too difficult), otherwise you simple don't know it.
It is context specific, when the context is known to the customer system where the code is running => You cannot activate a check in SU24 if it is not coded anywhere (please distingish between starting a transaction, using it, and navigating further from that transaction...). The only case where SAP does what you seem to be assuming (or hoping for...) is infact to turn an authority-check off in some cases or to make the calling context known when it is remote (in which case sy-tcode or the entry point context is not known)...
*It is not to turn the check on when it is not coded anywhere!!!
Perhaps you would like to phrase your final question just one more time.
Cheers,
Julius -
ABAP code in to JAVA for overwritting condition value for IPC pricing
Dear experts i am an IPC JAVA developer and i am trying to translate an ABAP Routine in to JAVA code for overwriting condition value in the pricing user exit of IPC
Here is the ABAPcode segment i am trying to transulate
DATA: l_kdkg1 LIKE komk-kdkg1,
l_work TYPE f,
l_umren LIKE marm-umren,
l_umrez LIKE marm-umrez.
SELECT SINGLE peinh FROM mbew INTO mbew-peinh
WHERE matnr = komp-matnr
AND bwkey = komp-werks.
I need some help in the following things
1. I don't know how to transulate the following Line of ABAP code into JAVA
" AND bwkey = komp-werks."
Bwkey stands for plant details. I don't know how to get plant details from Pricing Item.
2. Someone please tell me weather the following JAVA transulation is correct
Vector x = prItem.getUserExitConditions();
db database = pricingEngine.getDatabase();
// set table name
String tableStart = "mbew";
// set query parameters
sys_query_pair[] queryPair = null;
//matnr = komp-matnr . Getting the material Number
String materialNo= prItem.getProduct().toString();
//bwkey = komp-werks.Getting plant.
// TODO: werks stands for plant. Not sure how to get it from prItem
String plant = "";
queryPair = new sys_query_pair[2];
queryPair[0] = new sys_query_pair("matnr", materialNo);
queryPair[1] = new sys_query_pair("bwkey", plant);
// set query columns
String ZZFIELDStart = "peinh";
String ZZFIELD_VALUEStart;
String[] projectionStart;
projectionStart = new String[];
BigDecimal pricingUnit = null;
try{
// execute query
res resultSetStart = database.db_read_table(tableStart, queryPair,projectionStart) ;
if (!res.db_empty_results_p(resultSetStart))
ZZFIELD_VALUEStart = resultSetStart.db_get_row_element_string(0);
pricingUnit = new BigDecimal(ZZFIELD_VALUEStart);
resultSetStart.db_finish();
else
System.out.println("Coudn't find a value of field peinh in table mbew!");
catch (exc_database_error e)
e.printStackTrace();Please login to the server where IPC is installed. In the IPC folder u find libs folder or search for docs in IPC folder. There it is dealt how ABAP routines are mapped to user exits in java coding
Thanks
Surya -
ABAP CODE TO POPULATE LOGICAL SOURCE SYSTEM
Hi Friends please help me with the below
1. Requirement : to Populate The system Date , Source System
in BI for Each load request.
1 Solution: I thought of writing the Start Routine for this but it is giving me error
syntax Error: END METHOD MISSING?????
2. Also I have requirement to populate 0sourcsys source system id, can any body help how to populate that.
Thanks
Poonam Roy
ABAP Code.
I have the End Method. what more to do.
METHOD start_routine.
*=== Segments ===
FIELD-SYMBOLS:
<SOURCE_FIELDS> TYPE tys_SC_1.
DATA:
MONITOR_REC TYPE rstmonitor.
$$ begin of routine - insert your code only below this line -
... "insert your code here
FORM STARTROUTINE
USING G_S_MINFO TYPE RSSM_S_MINFO
CHANGING DATAPAK type TRANSTRU
ABORT LIKE SY-SUBRC.
DATA: ZLOAD_DAT LIKE SY-DATUM
ZZSOURSYS TYPE RSLOGSYS
IF G_S_MINFO-DATAPAKID=1
SOURCE_FIELDS-ZLOAD_DAT = SY-DATE.
SOURCE_FIELDS-ZZSOURSYS = G_S_MINFO-LOGSYS.
ENDIF.
ABORT = 0.
ENDFORM.
ENDMETHOD.
ENDCLASS.
*-- fill table "MONITOR" with values of structure "MONITOR_REC"
*- to make monitor entries
... "to cancel the update process
raise exception type CX_RSROUT_ABORT.
$$ end of routine - insert your code only before this line -
ENDMETHOD.You have to write the code (<b>in BI/BW</b>) in the transfer rule (<b>between Datasource transfer structure and infosource/info object</b>)
There the FORM begin with
[code]USING RECORD_NO LIKE SY-TABIX
TRAN_STRUCTURE TYPE TRANSFER_STRUCTURE
G_S_MINFO TYPE RSSM_S_MINFO
CHANGING RESULT TYPE /BI0/OIPERSON
G_T_ERRORLOG TYPE rssm_t_errorlog_int
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. set ABORT <> 0 to cancel datapackag[/code]
GS_MIN_INFO structure RSSM_S_MINFO contains information on the request being processed.
<i>G_S_MINFO. This passes technical information about the data load request,
such as requesting user, request date and time, update mode, the handling of
duplicate records, error handling flags, parallel processing flags, and what data
targets to update.</i>
If tou want to use start-routine for optimization reasons and fill an empty field in transfer structure, the structure G_S_MINFO is available too.
[code]USING G_S_MINFO TYPE RSSM_S_MINFO
CHANGING DATAPAK type TAB_TRANSTRU
G_T_ERRORLOG TYPE rssm_t_errorlog_int
ABORT LIKE SY-SUBRC. set ABORT <> 0 to cancel datapackage[/code]
And stay in FORM between limits :
[code]$$ begin of routine
$$ end of routine[/code]
Update RESULT in first case, and field(s) of DATAPAK in second case.
[code]RESULT = G_S_MINFO-LOGSYS.[/code] or
[code]LOOP AT DATAPAK INTO l_s_datapak_line.
l_s_datapak_line-zzsourcsys = G_S_MINFO-LOGSYS.
MODIFY DATAPAK FROM l_s_datapak_line.
ENDLOOP.[/code]
Regards -
ABAP code used in transaction SU01
Hi all,
Can anyone tell me that whether is there any method by which I can pass the user id and can know whether that user has the SAP_ALL profile or not.
The above is done by using the transaction SU01,but I need the ABAP code that is being used in this transaction.
Regards,
Varun.YOu can query the table:
UST04
select single * from UST04 where BNAME = sy-uname
and PROFILE = 'SAP_ALL'.
if sy-subrc = 0.
write:/ 'The User' sy-uname 'has SAP_ALL profile'.
endif.
Regards,
Ravi -
Implement activation key in ABAP code
In short:
I want to implement a way to control if certain ABAP code (certain logicial areas) are executed, by having the ABAP code prompting for an activation key.
Much like when you are promptet for a Developer access key or an object key for chaning sap standard code.
The long explanation:
We have som local developement in our system landscape that we want subsiduraies to request an access key if they want to go beond a certain point (or if they want to use this logical part of the develoment).
They should be promptet for an access key - which they then request from the head office.
A case could also be if we are developing an SAP Add-on using AAK (Add-on Assemply Kit) and we want to close of certain areas of functionality, these areas of functionality could then be opened by a access key requested from headoffice.
Question
Do you know how to impelment an access key feature in ABAP?For programs (SE38), you may implement EXIT_SAPLS38E_001 of extension SEUED001 (using CMOD transaction) to keep users from modifying programs:
IF operation = 'EDIT' AND
program IN <reserved_to_head_office> AND
sy-uname NOT IN <head_office_team>.
MESSAGE i001(00) WITH 'program reserved exclusively to head office'.
RAISE cancelled.
ENDIF.
For function modules (SE37), you may implement EXIT_SAPLS38L_001 of extension SEU00004:
IF operation = 'MODIFY' AND
objectname IN <reserved_to_head_office> AND
sy-uname NOT IN <head_office_team>.
MESSAGE e001(00) WITH 'this FM is reserved exclusively to head office'
RAISING cancelled.
ENDIF.
For methods (SE24), I don't know how to do it. I guess implicit enhancement option should be used.
Edited by: Rob Burbank on Mar 22, 2010 6:40 PM -
Trouble with SAPconnect / sending email in ABAP-code
Hi,
with the code below I try to send an email from ABAP outside
to an mail-account in the internet.
I'll get no error/exceptions but the mail will be not send
to the internet-mail-account.
In Transaktion SCOT I checked the SAPconnect-Node "INT"-"SMTP".
There is a mailserver with the right IP und the right Port. So I don't understand
what could be the problem!?
Can anybody help me and say me why the code below doesn't works?
Best wishes!
* For API
data: maildata type sodocchgi1.
data: mailtxt type table of solisti1 with header line.
data: mailrec type table of somlrec90 with header line.
start-of-selection.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test'.
maildata-obj_langu = sy-langu.
mailtxt-line = 'This is a test'.
append mailtxt.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'RAW'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* Start the send process using the following statement
submit rsconn01 with mode = 'int' and return.
Message was edited by:
sebastian eckesSAP is a robust system, which gives many facilities in the form of Function Modules (FMs) for connecting to external systems or for use within the system. With a clever use of these FMs we can achieve a lot of things through ABAP code.
This article focuses on ways to send E-mails and SAP Mails using ABAP code.
Firstly SAP Mail
A SAP mail is a mail internal to the SAP system. It is a very good forum to exchange information with other users. Using a SAP mail in ABAP code facilitates exchange of automatic messages at various stages of the business process. It is easy to use and saves many hassles involved in using workflows for exchanging messages.
The ABAP code to send a sap mail is built around the FM SO_OBJECT_SEND which has the following pattern.
call function 'SO_OBJECT_SEND'
exporting
EXTERN_ADDRESS = ' '
FOLDER_ID = ' '
FORWARDER = ' '
OBJECT_FL_CHANGE = ' '
OBJECT_HD_CHANGE = ' '
OBJECT_ID = ' '
OBJECT_TYPE = ' '
OUTBOX_FLAG = ' '
OWNER = ' '
STORE_FLAG = ' '
DELETE_FLAG = ' '
SENDER = ' '
CHECK_ALREADY_SENT = ' '
importing
object_id_new =
sent_to_all =
tables
OBJCONT =
OBJHEAD =
OBJPARA =
OBJPARB =
receivers =
PACKING_LIST =
ATT_CONT =
ATT_HEAD =
NOTE_TEXT =
exceptions
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
folder_not_exist = 4
folder_no_authorization = 5
forwarder_not_exist = 6
note_not_exist = 7
object_not_exist = 8
object_not_sent = 9
object_no_authorization = 10
object_type_not_exist = 11
operation_no_authorization = 12
owner_not_exist = 13
parameter_error = 14
substitute_not_active = 15
substitute_not_defined = 16
system_failure = 17
too_much_receivers = 18
user_not_exist = 19
x_error = 20
others = 21.
In the next article we will understand the main parameters and table interfaces of the FM.
Import Parameters Name and Description Field name Field function
Object_hd_change (structure) Contains the process to be done when SAP mail is marked for execution.When the Execute Icon in the SAP mail is clicked the corresponding object is executed vmtyp D for dialog module F for function moduleR for reportT for transactionU for transaction with export
Acnam Name of the object which is to be executed, like name of transaction/report
Skips X to execute first screen in background
Objsns Indicates sensitivity of the object. P for private objectF for functional objectO for confidential objectC for company confidential objectSensitivity level is restricted to O for documents in shared folders
Objla Language of the document E for Englishsy-langu for system language
Objnam Name of the document
Objdes Short description (Title) of the document
Objsrt Name of the sort field. This is used to group documents based on certain criteria
Object_type Type of document to be sent with mail RAW for raw text (default) DOC for word file XLS for excel fileAll classes can be used except for folders (FOL) and distribution lists (DLI)
Outbox_flag X to indicate that mail should also be stored in outbox of the user after sending (default )
Owner Sap login of the user responsible for transmission
Table Parameters Name and Description Field Name Field function
Objcont Table to hold the body of the mail Line Text lines up to 255 characters
Objhead Table to hold number of lines in the body of the mail, i.e size of the table in lines Line Text lines up to 255 characters
Objpara Table to hold the set/get parameters to be transferred to the processing element Name Name of the parameter. Only first three characters are used
Option Not used
Low Value of the parameter in name
High Not used
Objparb Table to hold information for mails to which a certain processing type is assigned. For a report or transaction with transfer of values to global memory, the table has to contain the parameters with relevant values. The memory id is taken from the first row. For a FM or dialog module, data in table will be transferred as table parameter msgdial Name For report or transaction with transfer of values to global memory, the field for first row should hold the name of the memory id used for export and the other rows should hold the parameter names. For FM or dialog module this field should hold the values as per the usage of the module
Value For report or transaction with transfer of values to global memory, the field for first row should remain empty and the other rows should hold values of the parameters. For FM or dialog module this field should hold the values as per the usage of the module
Receivers Table to hold recipient details Recnam SAP login of the recipient. Append all the recipients to this table
Sndcp X for sending mail as a copy
Sndex X for sending as express document. This will prompt a logged on recipient saying that he or she has received an express mail
Recesc B for SAP user E for external email addressU for unix address
Export Parameters Name and Description Field name Field function
Object_id_new Contains object id of document created during send process
Sent_to_all X indicates that document was sent to all recipients. Flag is not activated if sending fails in one or more cases
Main Exceptions Name and Description Description
Too_much_receivers Number of recipients is greater than number for which sender is authorised to send
Object_not_sent Document was not delivered to any of the recipients
Object_not_exist Document class specified does not exist or cannot be sent
Object_no_authorisation Document could not be sent as one of the required authorisations does not exist
Parameter_error Invalid combination of parameter values transferred to FM
X_error Internal error occurred
Once all the parameters and table interfaces are properly filled, call the function module to send the SAP mail to the recipient inbox.
Care should be taken to report the status of execution of the function module to the user using one of the exceptions defined (refer function module pattern above)
Though SAP mail is a very robust method of interacting with users within SAP system, it is always good to receive email in Microsoft inbox. This also works like an additional notification to users in case they do not check SAP mail regularly. The next article covers sending E-mails using ABAP.
Sending Email to a non-SAP system:
Though SAP mail is a very robust method of interacting with users within SAP system, it is always good to receive email in Microsoft inbox. This also works like an additional notification to users in case they do not check SAP mail regularly.
Sending an email to the Microsoft Inbox is a way of interacting with a non SAP system through ABAP code and hence is very interesting. A fair knowledge of UNIX shell scripting is assumed here.
The ABAP code to send an email to Microsoft inbox revolves around following UNIX script
Echo "From:" "<"$1">" > <unix file path name>
Echo "To:" "<"$2">" >> <unix file path name>
Echo "Subject:" "<"$3">" >> <unix file path name>
Cat $4 >> <unix file path name>
Uuencode $5 $6 >> <unix file path name>
Cat <unix file path name> | /usr/sbin/sendmail f $fraddr $toaddr
(Note : the commands in the above script can be case sensitive. Check the actual case on the unix installation in question)
Let us understand the various parts of the above script.
$1 = Sender email address
$2 = Recipient email address
$3 = Subject of the email
$4 = Path of unix server file having email body
Form email body as an internal table in ABAP program, download it to a unix server file
$5 = Path of unix server file to be sent as email attachment
$6 = Name to be given to the attachment (like test1.doc, test1.xls). The corresponding Microsoft icon
will be shown in the email for the type of file attached ( Word document, excel document etc)
The script builds a temporary file and pipes the file to the sendmail command to achieve the mission.
This script can be invoked from SAP to send the mail to the intended recipient. Store this small script on the unix server. (Assume script name is sndmail )
To do this we should define a link in the SAP system between a customized command and this unix script.
The FM to define a customized command in SAP system has the following pattern.
call function 'SXPG_CALL_SYSTEM'
exporting
commandname =
PARAMETERS = ' '
importing
status =
tables
exec_protocol =
exceptions
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
others = 12.
In the next article we will understand the main parameters and table interfaces of the FM.
Import Parameters Name and Description Field name Field function
Commandname Name of unix shell script or command to be executed by SAP Name of unix shell script to be invoked
Parameters The parameters to be sent to unix shell script ($1, $2 etc). Send parameters as a concatenated string separated by space and length not exceeding 128 characters For eg in UNIX environment the above shell script would be executed as Sndmail [email protected] [email protected] Trial /home/test.doc testmail.We will be simulating this command using the FM from SAP system
Table Parameters Name and Description Field Name Field function
Exec_protocol (structure) Table to get messages from unix server after shell script is executed Length Length of the message from external program i.e unix
Message Log message from external program i.e unix
Export Parameters Name and Description Field name Field function
Status Contains the status of execution of external program Scheduling status of external program i.e unix
Once the above FM is invoked with the necessary parameters the unix program sendmail will send a mail to the inbox of the recipient in Microsoft.
The restriction on the parameter string length of 128 characters can be removed to make way for very long email addresses and subjects. Build the parameters into an internal table and download it as a file on the unix server. Instead of passing each parameter individually, pass the unix server path of this file as the parameter to the unix shell script (sndmail mentioned above). Modify the shell script to read every line of this parameter file as variables to be used in the shell script.
In the next article we will see an example of the ABAP code you can use to send SAP Mails.
REPORT ZTSAPMAIL.
DATA: X_OBJECT_TYPE LIKE SOOD-OBJTP.
DATA: BEGIN OF X_OBJECT_HD_CHANGE.
INCLUDE STRUCTURE SOOD1.
DATA: END OF X_OBJECT_HD_CHANGE.
DATA: BEGIN OF X_OBJCONT OCCURS 10.
INCLUDE STRUCTURE SOLI.
DATA: END OF X_OBJCONT.
DATA: BEGIN OF X_OBJHEAD OCCURS 0.
INCLUDE STRUCTURE SOLI.
DATA: END OF X_OBJHEAD.
DATA: BEGIN OF RAW_HEAD.
INCLUDE STRUCTURE SORH.
DATA: END OF RAW_HEAD.
DATA: BEGIN OF X_RECEIVERS OCCURS 0.
INCLUDE STRUCTURE SOOS1.
DATA: END OF X_RECEIVERS.
PARAMETERS: RECEIVER LIKE X_RECEIVERS-RECNAM. " Name
*BUILD MESSAGE HEADER
MOVE 'Sort field goes here' TO X_OBJECT_HD_CHANGE-OBJSRT. " Sort field
MOVE 'Name of the object goes here' TO X_OBJECT_HD_CHANGE-OBJNAM. " Name
MOVE 'Document title goes here' TO X_OBJECT_HD_CHANGE-OBJDES. " Title
MOVE 'F' TO X_OBJECT_HD_CHANGE-OBJSNS. " Functional OBJECT
MOVE 'E' TO X_OBJECT_HD_CHANGE-OBJLA. " Language
Object type of the new document
MOVE 'RAW' TO X_OBJECT_TYPE.
CLEAR X_OBJCONT.
MOVE 'Contents of mail' TO X_OBJCONT-LINE.
APPEND X_OBJCONT.
CLEAR X_OBJCONT-LINE. APPEND X_OBJCONT.
MOVE 'More contents' TO X_OBJCONT-LINE.
APPEND X_OBJCONT.
MOVE 'Still more contents'
to x_objcont-line.
APPEND X_OBJCONT.
MOVE ' ' TO X_OBJCONT-LINE.
APPEND X_OBJCONT.
Specific header (Dependent on the object type, here RAW)
REFRESH X_OBJHEAD.
DESCRIBE TABLE X_OBJCONT LINES RAW_HEAD-RAWSIZ.
MOVE RAW_HEAD TO X_OBJHEAD.
APPEND X_OBJHEAD.
*RECEIVERS table
CLEAR X_RECEIVERS.
REFRESH X_RECEIVERS.
MOVE RECEIVER TO X_RECEIVERS-RECNAM. " Name
MOVE 'B' TO X_RECEIVERS-RECESC. " Receiver type
MOVE 'X' TO X_RECEIVERS-SNDCP. " Send as a copy
MOVE 'X' TO X_RECEIVERS-SNDEX. " EXPRESS DOCUMENT
APPEND X_RECEIVERS.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
folder_id = 'OUTBOX'
forwarder = x_forwarder
object_fl_change = x_object_fl_change
OBJECT_HD_CHANGE = X_OBJECT_HD_CHANGE
object_id = x_object_id
OBJECT_TYPE = X_OBJECT_TYPE
OUTBOX_FLAG = 'X'
OWNER = SY-UNAME
store_flag = x_store_flag
importing
object_id_new = x_object_id_new
sent_to_all = x_sent_to_all "May need to use
TABLES
OBJCONT = X_OBJCONT
OBJHEAD = X_OBJHEAD
objpara = x_objpara
objparb = x_objparb
RECEIVERS = X_RECEIVERS.
REPORT ZTUNIXMAIL.
DATA : TO_ADDRESS LIKE SY_LISEL,
FROM_ADDRESS LIKE SY-LISEL,
SUBJECT LIKE SY-LISEL,
ATTACHMENT_NAME LIKE SY_LISEL,
DATA_FILE_PATH LIKE SXPGCOLIST-PARAMETERS,
BODY_FILE_PATH LIKE SXPGCOLIST-PARAMETERS.
DATA : BEGIN OF INT_EMAIL_ATTACH OCCURS 0,
TXTLINE CHAR(255),
END OF INT_EMAIL_ATTACH.
DATA : BEGIN OF INT_EMAIL_BODY OCCURS 0,
TXTLINE CHAR(255),
END OF INT_EMAIL_BODY.
CLEAR : INT_EXEC_PROTOCOL,INT_EMAIL_ATTACH,INT_EMAIL_BODY.
REFRESH : INT_EXEC_PROTOCOL,INT_EMAIL_ATTACH,INT_EMAIL_BODY.
INT_EMAIL_ATTACH-TXTLINE = 'Put all attachment text in this table'.
APPEND INT_EMAIL_ATTACH. CLEAR INT_EMAIL_ATTACH.
INT_EMAIL_BODY-TXTLINE = 'Put all attachment text in this table'.
APPEND INT_EMAIL_BODY. CLEAR INT_EMAIL_BODY.
CONCATENATE TO_ADDRESS
FROM_ADDRESS
SUBJECT
BODY_FILE_PATH
DATA_FILE_PATH
ATTACHMENT_NAME
INTO V_PARAMETERS.
IF NOT INT_EMAIL_ATTACH[] IS INITIAL.
OPEN DATASET DATA_FILE_PATH FOR OUTPUT IN TEXT MODE.
LOOP AT INT_EMAIL_ATTACH.
TRANSFER INT_EMAIL_ATTACH-TXTLINE TO DATA_FILE_PATH.
ENDLOOP.
CLOSE DATASET DATA_FILE_PATH.
ENDIF.
IF NOT INT_EMAIL_BODY[] IS INITIAL.
OPEN DATASET BODY_FILE_PATH FOR OUTPUT IN TEXT MODE.
LOOP AT INT_EMAIL_BODY.
TRANSFER INT_EMAIL_BODY-TXTLINE TO BODY_FILE_PATH.
ENDLOOP.
CLOSE DATASET BODY_FILE_PATH.
ENDIF.
CALL FUNCTION 'SXPG_CALL_SYSTEM'
EXPORTING
COMMANDNAME = 'Z_EMAIL' - Command calling unix script
PARAMETERS = V_PARAMETERS
importing
status = ''
TABLES
EXEC_PROTOCOL = INT_EXEC_PROTOCOL
EXCEPTIONS
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
OTHERS = 12.
regards,
srinivas
<b>*Reward points for useful answers*</b> -
How to add breakpoint in abap code
when use <i><b>java</b></i> call abap code ,
how to add breakpoint in abap code?Hi,
To start the ABAP debugger from your java client you have to set the JCO client to debug mode:
e.g.
yourJCOClient.setAbabDebugMode(true)
(hope thats the right method name:-)).
And don't forget to set also a break point of type "External" in the function module you call from your java client. For debuging, the user which calls the FM has to be a SAP User of type "<b>Dialog"</b> and has to be the rights to call RFCs, ...
Maybe you are looking for
-
Install OS 9 from Hard Disk?
Hello, Can I install OS 9 from the hard drive. I have a USB Hard Drive Caddy, so I can put the files on and stuff. It is an iMac G3 that needs an updated firmware, but it has a broken CD-Rom. Once I am finished installing OS 9 and upgrading the firmw
-
HT1918 I can't use me account in iTunes
I can't use my account in I tunes
-
I have iPhoto and it remains to be the most difficult thing for me to learn. I have never quite figured it out, and no matter what I do, I cannot get rid of a single photo to save my life. Sure, I can delete hundreds of photos but they ALWAYS return
-
Can I measure dynamic strain with a SCXI-1531 and how steady is the excitation current?
I am looking at the possibility of using an SCXI-1531 module to take measurements from a single strain gauge. I am only interested in the dynamic content of the signal and so am considering using the constant current excitation method which does not
-
Hi, I'm trying to add objects into a LinkedList in such a way that they are always kept in alphabetical order. But im having problems and errors galore. Here is the code i have so far: public void add(Account a) if (accounts == 0)