ABAP Code + API
Hello Friends,
I have to write a method in ABAP equivelent to java method, here is the jave source code.
private String constructID(String id)
StringBuffer str = new StringBuffer("0000000000");
str.append(id);
return str.substring(id.length());
(Just explain shortly what it is doing!)
I am trying to call the BAPI (BAPI_BUPA_CENTRAL_GETDETAIL), and in oder to call this BAPI I have to export the BUSINESSPARTNER parameter. This parameter has been stored in DB with 10 char e.g 0000000001 . As I am developing web interface so the user can enter BUSINESSPARTNER No = 1, and this java code will map the user enter 1 to 0000000001.
I want to ask, is there online API avaiable for ABAP which helps me to write this equivelent code or is there any method like append() or subString() in ABAP ( as I am very new to ABAP so please excuse me if I bothers you )
Many thanks!
Marek.
If I understand correctly, you need to make "1" look like "0000000001" using ABAP code. Try the following code. This should work for you.
Regards,
Rich Heilman
report zrich_0004 .
data: char(10) type c value '1'.
data: numc(10) type n.
numc = char.
write:/ char.
write:/ numc.
Similar Messages
-
Calling a mime object in the WebDynPro ABAP code dynamically
Hi ,
Can anyone let me know the API to access the mime objects dynamically in the WD ABAP code. I have a text file in the WD ABAP component as a text file.
I would like to pick the file with the help of API's and read the content of the file using Mime Object API's .
Can anyone help me out in this.
Best Regards
SidHi,
do the methods of CL_WD_WEB_ICON help?
Regards, Heidi -
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 write ABAP code behind, the OLAP navigation functions
Hi SDN Community,
We have created an artificial hierarchy within BEx, using order structure elements, or characteristic key figures as SAP calls them.
Now, the only feature that dosent seem to be present within the OLAP, is to expand all hiearchy nodes.
It allows you to expand one hierarchy node, but not all the structure element nodes.
I have tried command sequencing by specifying the technical id's of the the structure elements found via RSRT2, but this dosen't work.
I have seen that when the nodes are expanded, that there is indeed standard SAP ABAP code executing back in the datawarehouse.
Hence, do you know
- Where to make ABAP enhancements for OLAP functionality
- How to execute this ABAP (will it be by using Web API and javascript enhancements)
- Is this possible, or has it been done by anyone?
Thank you.
SimonHi Thomas,
I have been working with a brilliant ABAP'er, and together we
implemented a solution in the START method, that makes use of the
following methods and expands all the hierarchy nodes at start.
And this class can be omitted in the Print all view we have formulated
as only a collapsed view has been specified there.
thank you.
Simon
I found this all in that class interface CL_RSR_REQUEST
for N_R_REQUEST
for N_R_DATA_SET
Initial Value: Set Drilldown State of a Hierarchy
Description: 'SET_DRILL_STATE'
this looks like the method that gets executed. what do you think?
can you code this in the program
constants C_CMD_SET_DRILL_STATE type RSRCMDID
value 'SET_DRILL_STATE'. "#EC NOTEXT
methods SET_DRILL_STATE
importing
value(I_AXIS) type RRXAXIS optional
value(I_POSITION) type I optional
value(I_FOCUS_IOBJNM) type RSIOBJNM optional
value(I_DRILLSTATE) type RRXDRILLSTATE optional
value(I_TOGGLE) type RS_BOOL default RS_C_FALSE
!I_R_PARAMETER type ref to CL_RSR_PARAMETER optional
exporting
!E_KEEP_LAST_LINES type I
!E_KEEP_FIRST_LINES type I
!E_NEW_LINES_FROM type I
!E_NEW_LINES_TO type I
!E_NODE_POSITION_FROM type I
!E_NODE_POSITION_TO type I
exceptions
NO_PROCESSING
X_MESSAGE . -
Executing an HTTP Request in ABAP Code
Hi,
I have to write an ABAP program to check VAT numbers before making any VAT declaration. SAP checks the logic of the number, however it does not check if a VAT number is still valid for that company. The European Commission has a website (http://ec.europa.eu/taxation_customs/vies/) where you can check centrally all VAT numbers used in the EU. According to the Commission's web site it should be possible to have an open interface. A SOAP service is available (Its WSDL file can be obtained also on the website).
Does anyone has an idea how this can be done (Current SAP version = SAP ECC 6.0) taken into account there is no XI (or IP) aviable or set up or used.
Thanks,
JanHi,
The examples are calling a browser but that is not what we are looking for. What we are looking for is (via ABAP) to send our http request and receive back the anwser. They (http://ec.europa.eu/taxation_customs/vies/) provide the SOAP message (WSDL : (http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl). My question is if it is possible witout using XI and yes how? If I understand it correctly is should be possible via ABAP (example program RSWF_TEST_HTTP), but if I create my own program I get the message HTTP-Receive: RC=400 ICM_HTTP_CONNECTION_FAILED. Maybe the ABAP code is correct, but maybe I should change some settings or configure something else.
Jan -
Abap MDM API query with OR operation
Hi experts,
not sure this is the proper section for the thread, anyway; dealing with ABAP MDM API, is there a way to build up a query which involves several clause in OR conjunction?
This is the scenario: I've got to extract several items on the basis of exact product codes. Tipically, I've got huge vectors of hundreds of product codes; actually, I could easily retrieve data by looping over them and, for each code, perform a query on MDM via QUERY method building the clause as follows:
ls_query-parameter_code = 'MDMSRM_PART_NO'. "Field code
ls_query-operator = 'EQ'. "Contains
ls_query-dimension_type = mdmif_search_dim_field. "Fieldsearch
ls_query-constraint_type = mdmif_search_constr_text. "Text search
lv_text = wa_codes-product_code.
GET REFERENCE OF lv_text INTO ls_query-value_low.
APPEND ls_query TO lt_query.
This will however result in hundreds of query in the LOOP itself.
Is there any way to build a query with OR operators ?
Thanks,
M.Hi,
I see you are not clearing your local structure "ls_query". This could be reason of problem, try this and let us know the result:
DATA lt_query TYPE mdm_query_table.
DATA ls_query TYPE mdm_query.
DATA lv_search_text TYPE string.
DATA lt_result_set TYPE mdm_search_result_table.
DATA ls_result_set LIKE LINE OF lt_result_set.
Fill query structure with FIRST parameter
ls_query-parameter_code = 'Name'.
ls_query-operator = 'CS'.
ls_query-dimension_type = mdmif_search_dim_field.
ls_query-constraint_type = mdmif_search_constr_text.
lv_search_text = 'BMW'.
GET REFERENCE OF lv_search_text INTO ls_query-value_low.
APPEND ls_query TO lt_query.
CLEAR ls_query.
Fill query structure with SECOND parameter
ls_query-parameter_code = 'Model'.
ls_query-operator = 'CS'.
ls_query-dimension_type = mdmif_search_dim_field.
ls_query-constraint_type = mdmif_search_constr_text.
lv_search_text = '2009'.
GET REFERENCE OF lv_search_text INTO ls_query-value_low.
APPEND ls_query TO lt_query.
CLEAR ls_query.
Query on records (search for value 'BMW' model '2009' in table Products)
CALL METHOD lr_api->mo_core_service->query
EXPORTING
iv_object_type_code = 'Products'
it_query = lt_query
IMPORTING
et_result_set = lt_result_set. -
Create account/customer hierarchy thru ABAP codes
Hi,
Anyone can help me on how to create a account/customer hierarchy in CRM.
How can I create node, assign BP to a account/customer hierarchy.
Can anybody share some abap codes that can do this? Or give some FMs or documentation on how to do this.
Thanks!
jamesJames,
You can find the FM, Class Lib and APIs under the package BUPA_HIERARCHY. -
Help regarding calling BRFPLUS function through ABAP code
Hi,
I have a situation where I have to input data into a BRFPLUS function as a table (i.e the data is input as select options where list or range of data can be provided).The corresponding output is also in the form a table .I've created this function in BRFPLUS and is working fine .Now I have to call it through ABAP code.Can someone kindly provide me with the probable code for this scenario.
E.g:
ZT_MATNR is the table in brfplus representing the list of MATNR values input along with other such inputs to function module Z_FM
ZT_ATM is the resultant output table of the function which contains several fields.
Now I have to call this BRFPLUS function with help of ABAP code.Could someone kindly help.Hello ,
There should be a number of BRF+ tutorials available in SCN which discuss the FDT APIs. You can have a look at them to get an idea of the various APIs available and their uses.
For your usecase, you should do the following.
lo_fdt_function TYPE REF TO if_fdt_function,
lo_fdt_result TYPE REF TO if_fdt_result,
* Get function handle
CALL METHOD lo_fdt_factory->get_function
EXPORTING
iv_id = lv_function_id
RECEIVING
ro_function = lo_fdt_function.
where lv_function_id is the GUID of the BRF+ function . You can either make it a constant , or you can use a FDT API to get the function GUID from the BRF+ application name and function name.
* Set function context
TRY.
CALL METHOD lo_fdt_context->set_value
EXPORTING
iv_id =
ia_value =
This is one way to set the input context ( pass the input to the BRF+ function to process ). There are other ways to do this as well. Which one you use would depend on the kind of input you want to pass.
* Execute BRFPLUS function
TRY.
CALL METHOD lo_fdt_function->process
EXPORTING
io_context = lo_fdt_context
IMPORTING
eo_result = lo_fdt_result.
* Get result output
TRY.
CALL METHOD lo_fdt_result->get_value
IMPORTING
ea_value =
Another direct way of doing it would be to use the method PROCESS of the class CL_FDT_FUNCTION_PROCESS.
I have not gone into much explaination here , but it should provide you an idea of how you can go about it.Read the SCN docs on the APIs to get a better idea , or better still if you can get hold of a copy of the BRF+ book by Carsten Ziegler , you will get an end to end explaination of all BRF+ APIs in it.
Regards,
Indranil. -
Create CRM customer/account hierarchy node thru abap code
Hi,
Any one can help me on how to Create CRM customer/account hierarchy node thru abap code?
Is there any Class/methods, FMs that I can use to create node in customer/account hierarchy?
Sample codes will greatly help me.
I hope someone can help me on this since this is my urgent requirements on my project.
Thanks,
jamesJames,
You can find the FM, Class Lib and APIs under the package BUPA_HIERARCHY. -
Creating an xml file from abap code
Hello All,
Please let me know which FM do I need to execute in order to create an XML file from my ABAP code ?
Thanks in advance,
Paul.This has been discussed before
XML files from ABAP programs -
Hi All,
I need to use unix command (MOVE) in ABAP code for transfering a file from one directory to another directory.
Can any one help with how to used unix commands in ABAP?
Thanks in advance.
Regards,
HemendraThe recommended approach always used to be to use transaction SM69 to define a "soft" command name to the operating system command so that it could be configured to work across Windows, Unix etc. For example:
Command name OS Type OS command Parameters for operating system command
Z_FILE_MOVE SunOS Customer mv ? ?
You can then call function module SXPG_COMMAND_EXECUTE (quite well documented) to actually perform the command passing in the appropriate number of parameters.
Jonathan -
Needs sample ABAP code for field routine
Dear Expert,
There is a field "Pay Scale Group" in my DSO which stores the data in the format
AA1/B1/CCC2/DD2/EEE1, A1/BB2/CC2/DDD3/EE2 etc. These data has to be transferred to
InfoCube where "pay Scale Group" in the InfoCube will store the data like EEE1,EE2 etc.
I need to write a field routine on the transformation between DSO and Cube.
Can any one please help me with the sample ABAP code for this scenario.
Some more examples for better understanding of the requirement:-
Data in DSO(Source) Data in Cube(Target)
=================== ===================
AA1/B1/CCC2/DD2/EEE1 EEE1
AAA1/BB2/CC1/DDD3/EE2 EE2
A2/BBB2/CC2/DDD3/EEE5 EEE5
AA2/BB1/C1/DDD3/EE3 EE3
A3/B1/CC2/DDD1/EE4 EE4
Many thanks in advance.
Regards,
Prakash
Please do not dump your code requirements in SDN
Edited by: Pravender on May 18, 2011 11:37 AMHi,
You can use the following code :
Suppose the technical name of the field coming from DSO is ZPAY_SGRP.
And also for example let me take one record, that is ZPAY_SGRP = AA1/B1/CCC2/DD2/EEE1 .
My assumption is that there will always be 4 '/'.
In the field routine write the below code
data: V1(5) type c,
V2(5) type c,
V3(5) type c,
V4(5) type c,
V5(5) type c.
data : VAR1 TYPE /BIC/OIZPAY_SGRP.
split VAR 1 at '/' into V1 V2 V3 V4 V5.
result = V5.
V5 will be having the characters after the last '/' .That is V5 = EEE1.
Hope the above reply was helpful.
Kind Regards,
Ashutosh Singh
Edited by: Ashutosh Singh on May 17, 2011 3:53 PM
Edited by: Ashutosh Singh on May 17, 2011 4:17 PM -
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. -
ABAP code for BI 7.0 transformations start routine
Hi all,
I am trying to update data from DSO1 (Source1: transaction data) to Infocube(TARGET)
In the transformations Start routine, I have to read DSO2(Source2: Master data) for some fields.
DSO1 has CUSTOMER as part of key
DSO2 has CUSTOMER (key) and other fields....FIELD1, FILED2, FIELD3
Infocube to be updated with FIELDS1,2 & 3 WHILE READING DSO2.
WHERE DSO1 CUSTOMER matches with DSO2 CUSTOMER.
Also, data NOT TO BE UPLOADED into Infocube if FIELD1 in DSO2= NULL
Please give me the abap code for the above logic.
Appreciate any help in this regard.
Thanks.This is a doc from this site:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6090a621-c170-2910-c1ab-d9203321ee19
Ravi Thothadri -
ABAP code needed to convert from 0calmonth2 & 0calyear to 0calmonth
Hi SAP GURUS,
Can anybody give me the ABAP code to convert from 0calmonth2 and 0calyear to 0calmonth.and please suggest me whether i have to write start routine or end routine in transformations.
Thanks ALL.hi,
in the transformation map 0calmonth2 and 0calyear to the 0calmonth field, and from drop down choose routine.
there will be an area where it will be mentioned write your piece of code below this line.
paste the below code:
Concatenate source_fields-0calmonth2 source_fields-0calyear into result.
also delete the line result = .
save the routine and execute the package.
regards,
Arvind.
Maybe you are looking for
-
Expdp/impdp :: Constraints in Parent child relationship
Hi , I have one table parent1 and tables child1, child2 and chld3 have foreign key created on this parent1. Now I want to do some deletion on parent1. But since number of records are very high on parent1 , we are going with expdp / impdp with querry
-
Basic Flow Of SD and T-Codes , Tables
Hi Im SA-BW Consultant . I want some basic knowledge for SD . I mean the flow of SD and Basica Tables and transactions . Pls let me know kumar
-
I can use this videocard in a MSI 970a-g46MOBO
HI I can use this videocard in a MSI 970a-g46MOBO PNY VCGGTX7803XPB-CC-OC GeForce GTX 780 3GB 384-Bit GDDR5 PCI Express 3.0 x16 SLI Support Video Card XLR8 Enthusiast Edition Thanks
-
Tabular report with variable-height 2nd line?
I have a simple tabular (Tablix) report. The last field is a message (varchar(1000)) which I would like to place by itself on a second line (while still preserving the tabular format), with variable height. The problem is, when I add a second row
-
Where did my migrated files go
I followed the instructions to migrate files from my PC to a Mac. I am a first time user of Mac and cannot locate the files. I migrated "my documents" some music and email.