ABAP Code Required to remove #
Hi,
I have 2 characteristics 0COORDER and 0WBS_ELEMT value for which do not exist for all the data records. As a result I get # in the report. How do I replace # in the report with blank? I dont want to use the VB Script, need a permanent fix. Where should I write ABAP routine for that and also please can anyone give me the ABAP code too.
Thank you,
sam
in bex, you can use vba macro. in web, use table interface
replacing '#'-sign for 'not assigned' in queries
SAPBEXonRefresh()
Dim c as range
For Each c in resultArea.cells
if c.Value = "#" then c.Value = "-"
Next c
or
by Jens (consider to performance)
put in SAPBEXonRefresh()
resultArea.Select
Cells.Replace What:="#", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows,
MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
table interface, redefine CHARACTERISTIC_CELL method...
if I_CHAVL = '#'.
c_cell_content = ' '.
endif.
Hope it helps.
Regards
Similar Messages
-
Hi Gurus,
I have three tables TAB1 (KEY1), TAB2(KEY1) and TAB3. I need to select records from TAB1 where the KEY1 is not present in TAB2.
for example if the key values of records in TAB1 are 1, 2, 3, 4, 5. and Key values of records in TAB2 are 1,2,3. I need to write code to select records in TAB1 with keys 4 and 5.
Finally, I have to append these 4 and 5 records to TAB3. TAB3 has some fileds similar to TAB1 and also some extra fields.
Can anyone please help me with the code in ABAP.
Thanks
Regards,
aarthi
[email protected]Hi Aarthi,
kindly check this code:
Loop at TAB1.
Read table TAB2 with key KEY1 = TAB1-KEY1.
if sy-subrc NE 0.
TAB3-KEY = TAB1-KEY1.
APPEND TAB3.
endif.
clear TAB2.
endloop.
hope this helps!
best regards,
Thangesh -
hi,
i have a dso which is having 100 fields
when i am loading data into dso i am getting error due to invalid charectors like #
so i need to write a code in start routine
so that i will check all the fields in dso and replace # with blank space
i checked with a code for one field but i want a code for all fields in the dso
i think this is possible in start routine
can any one suggest me some code for that
this code is for only one field but i want for 100 fields <b>so how to write it in start routine?</b>
DATA: h_string(40) TYPE c.
DATA: l_len TYPE i.
CONSTANTS: c_valid(58) TYPE c VALUE
' !"%&()''*+-/,.<>=;:?_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
h_string = source_field-CRM_DESCR.
REPLACE ALL OCCURRENCES OF '#' IN h_string WITH space.
WHILE NOT h_string CO c_valid.
h_string+sy-fdpos(1) = ''.
ENDWHILE.
result = H_STRING.Hi,
This is something one typically solves with field symbols
( see also http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm)
You define it:
data: i_fieldname(7) type C, tmp_string type string.
field-symbols: <a_field_name> type any.
do 100 times.
tmp_string = sy-index.
concatenate 'field' tmp_string into i_fieldname.
assign (i_fieldname) to <field_name1>.
REPLACE ALL OCCURRENCES OF '#' IN <field_name1> WITH space.
enddo.
That is if all variables start with the same.
If not, an alaternative might be that you put all field names in a table and then work also with field symbols.
Eddy
PS. Which type of SDN Ubergeek/BPX suit are <a href="/people/eddy.declercq/blog/2007/05/14/which-type-of-sdn-ubergeekbpx-suit-are-you">you</a>? -
Need ABAP code for the below Services requirement
Hi,
We have a requirement to show all the services for a particular Purchase order number.For this I built a view on 2 tables ESLL and EKPO.Now based on the below logic I need to bring the services for the Purchase order..
1.Enter PO number,item no. and Doc category in EKPO and find the Pack no.
2.Now take the Pack no. of EKPO and give in ESLL and find the Sub pack no.
3.Now take this Subpack no. and Give this sub pack as Pack no. in ESLL
4.This will be the Service entry record for that PO number.
Can any one Please suggest me to how to write the ABAP code for the above logic.
Thanks & Regards,
DinakarHi Dinaker,
Did you find any solution for this issue. I too have a similar requirement of pulling all the service orders for a specific Purchase Order in the BW report.
Thanks,
SAPBWI -
Not able to remove the ABAP code from Transformation
Hello Experts,
We have transformation for DSO in that for one infoobject, field routine is written, Break Point is hard coded there and it's move to production. Now we are trying to remove that break point from development and then move it production.
we are doing following activity to remove the break point.
1. Open the transformation.
2. Open the field routine.
3. Going to ABAP code in field routine.
4. Remove the hard coded Break Point from ABAP code.
5. Saving the code.
6. It's taking to again filed routine window.
7. We close the window and activate the transformation.
8. When again check the ABAP code in field routine then it shows hard coded Break Point again.
9. Not able to remove the hard coded break point.
Can anyone know how to do this.
Help will be appreciated.
ThanksHi,
As pointed above, after point 6 don't simply close the window but click on Transfer Value and then activate your transformation. Refresh the system and check again.
Regards,
Arminder -
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> -
Need ABAP code to make unique hierarchy values - Request prompt help
hi
<removed>
I am new to SAP. Please help me in the following
I require an ABAP code for the following scenario
I have a simple hieraarchy. The hierarchy is
SEG -> fam -> clas -> comm
The values of the seg , fam, cla, com......all will be charecter values
But in some cases the values will be NOT_KNOWN
If the values are NOT_KNOWN i need to change them as NOT_KNOWN_1, NOT_KNOWN_2...like that unique charecter values
should be replaced for NOT_KNOWN
Example
SEG->FAM->CLA ->COM
Clothing -> Mens wear -> Designer garments -> NOT_KNOWN
Construction -> equipments -> machinery->NOT_KNOWN
Computers -> Laptops -> Imported -> NOT_KNOWN
-> desktops ->flat monitors -> Indian
-> imported -> NOT_KNOWN->
NOT_KNOWN -> baggages
This should be changed to
SEG->FAM->CLA ->COM
Clothing -> Mens wear -> Designer garments -> NOT_KNOWN_1
Construction -> equipments -> machinery->NOT_KNOWN_2
Computers -> Laptops -> Imported -> NOT_KNOWN_3
-> desktops ->flat monitors -> Indian
-> imported
-> NOT_KNOWN_4 ->
NOT_KNOWN_5 -> baggages
This is to make them unique nodes to upload them in hiereachy
Data is coming from database tables and i was not supposed to do anything in database and the incomin
data needs to finetuned like this to update them in cube
So I like to have some coding which will enable this to work in the start routine
If start routine is not the right option, where else we can do coding
<removed>
Regards
KCdata : w_suff_n(8) type n,
w_suff_c(8).
loop at data_package.
if data_package-<fieldval> = 'NOT_KNOWN'.
w_suff_n = w_suff_n + 1. w_suff_c = w_suff_n.
shift w_suff_c left deleting leading '0'.
concatenate data_package-<fieldval> w_suff_c into data_package-<fieldval>.
modify data_package.
endif.
endloop.
*Change <fieldval> in the above to the actual field name. -
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 -
Enhancement-ABAP Code-Customized Field issue
Hi Experts,
Currently I am working on the BW3.5 version. We are using the standard SRM standard extractor 0BBP_TD_SC_1 and we enhance same extractor(populate the filed through CMOD - ABAP Code) with one customized field also. We are having issue on the customized field data which post from SRM system. I have verified the field value and value is fine in RSA3 in SRM source system. But while posting into the BW(PSA itself), its loading correct & wrong value. When i check the PSA for the particular load, It looks little strange. In the PSA, I can see correct value on my first record of the same SC and then next records has incorrect value of the same SC. Currently I am using the ODS as a data target. So finally i am getting the incorrect value on the customized field.
Ex Scenario:
Ex Customized Field: ZORGID
In SRM source system RSA3 Extractor Checker value:
Shopping Card No: 100
Customized Field: ZORGID=1
Shopping Card No: 200
Customized Field: ZORGID=2
In BW posting-PSA:
Shopping Card No: 100
Customized Field: ZORGID=2
Shopping Card No: 200
Customized Field: ZORGID=2
At the same time, if i do the selective deletion of the particular Shopping Card or group of SC in BW and do the full repair, then it gets a correct ZORGID=1 for the same Shopping Card.
I strongly believe, something wrong in the ABAP code. But when we tried to debug the customized filed value in RSA3. The value is fine. so we unable to trace out the issue. Please help me to fix the code. Thanks in advance.
CMOD ABAP Code:
*Populate approver ID even though it doesn't require approval this is required to make sure BW reports have restrict access to respective Org Unit approvals only
IF l_s_bbp_sc-approver_id IS INITIAL AND l_s_bbp_sc-itm_guid IS NOT INITIAL.
CALL FUNCTION 'Z_BBP_FIRST_APPROVALGET'
EXPORTING
iv_header_guid = l_s_bbp_sc-guid
iv_itm_guid = l_s_bbp_sc-itm_guid
IMPORTING
approver_no = l_s_bbp_sc-approver_id
EXCEPTIONS
no_data = 1
OTHERS = 2
IF sy-subrc 0.
ENDIF.
ENDIF.
To ensure that the Org Unit passed in into the field
l_s_bbp_sc-zzapprov_orgunit belongs to the Actual Level 1
Budget Owner and not any other manager such as Added Approver.
CLEAR : ls_ln_approvers, l_userid, lv_bpartner_guid.
DATA : lv_f_apprv_part TYPE BU_PARTNER.
READ TABLE lt_ln_approvers INTO ls_ln_approvers
WITH KEY INITIAL_INDEX = '0000000001'.
IF sy-subrc EQ 0.
MOVE ls_ln_approvers-approval_agent+2(12) TO l_userid.
CALL FUNCTION 'BP_CENTRALPERSON_GET'
EXPORTING
iv_username = l_userid
IMPORTING
ev_bu_partner_guid = lv_bpartner_guid
EXCEPTIONS
no_central_person = 1
no_business_partner = 2
no_id = 3
OTHERS = 4.
IF sy-subrc = 0.
CALL FUNCTION 'BUPA_NUMBERS_GET'
EXPORTING
iv_partner_guid = lv_bpartner_guid
IMPORTING
ev_partner = lv_f_apprv_part.
ENDIF.
ENDIF.
We get the BP number of the first Budget Owner 1
Here, we superseed the field l_s_bbp_sc-approver_id
whereby it may be wrong due to Added Approver.
IF l_s_bbp_sc-approver_id IS NOT INITIAL.
IF lv_f_apprv_part IS NOT INITIAL.
IF l_s_bbp_sc-itm_guid IS NOT INITIAL.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'BP'
act_objid = lv_f_apprv_part
act_wegid = 'EBP-UP'
act_begda = sy-datum
act_endda = sy-datum
act_tdepth = 4
TABLES
result_tab = lt_result_tab
EXCEPTIONS
no_plvar_found = 1
no_entry_found = 2
OTHERS = 3
IF sy-subrc = 0.
READ TABLE lt_result_tab INTO ls_result_tab WITH KEY
otype = 'O'.
IF sy-subrc EQ 0.
l_s_bbp_sc-zzapprov_orgunit = ls_result_tab-objid.
ELSE.
ENDIF.
ENDIF.
ENDIF.
Thanks,
RRHi Experts,
Any suggestions. Thanks.
Thanks,
RR -
IDOC: How to create child segment with abap code.
Hi,
I'am trying to write an abap code to create segments for an Idoc which structure is the following:
ZLE_00060_DLVY
> E1EDL20
> Z1DEL_CONS
>Z1DEL_MAT_HEADER
> Z1DEL_MAT
> E1EDL20RET2
> E1EDL22
> E1EDL21
> E1EDL23
> E1EDL51
I receive a sintax error: Error in IDoc with status 26 .
Checking the result I note all segment at the same level and an error about the segment E1EDL22
EDI: Syntax error in IDoc (segment cannot be identified)
Message no. E0078
Diagnosis
The segment E1EDL22 does not occur at the current level of the basic
type DELVRY05 (extension ZLE_00060_DLVY).
This error can have several reasons:
o The segment E1EDL22 is assigned to a group whose header segment does
not occur.
o The segment E1EDL22 does not exist in the syntax description of the
basic type DELVRY05 (extension ZLE_00060_DLVY).
o The sequence of segments in the group in which the segment appears
is incorrect.
Previous errors ('mandatory' segment or group missing) may be due to
this error.
Procedure
Please check the IDoc or the syntax description of the basic type
DELVRY05 (extension ZLE_00060_DLVY).
After the error I have:
data records
E1EDL20
Z1DEL_CONS
Z1DEL_MAT_HEADER
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
E1EDL20RET2
E1EDL22
E1EDL21
Abap code:
idoc_data-segnam = 'Z1DEL_CONS'.
idoc_data-sdata = s_z1del_cons.
append idoc_data.
idoc_data-segnam = 'Z1DEL_MAT_HEADER'.
s_z1del_mat_header-tsegment = 'MATERIAL'.
idoc_data-sdata = s_z1del_mat_header.
append idoc_data.
clear idoc_data-sdata. <<<<<<<<<<< how to indent the structure because this is a child.
idoc_data-sdata = s_Z1DEL_MAT.
idoc_data-segnam = 'Z1DEL_MAT'.
append idoc_data.
idoc_data-segnam = 'E1EDL20RET2'.
idoc_data-sdata = s_E1EDL20RET2.
append idoc_data.
clear idoc_data.
idoc_data-segnam = 'E1EDL22'.
idoc_data-sdata = s_e1edl22.
append idoc_data.
clear idoc_data.
idoc_data-segnam = 'E1EDL21'.
idoc_data-sdata = s_e1edl21.
append idoc_data.
Any help will be well appreciated.
Thanks in advance.
Regards,
GiovanniHi,
following in debugging mode the abap code of the INCLUDE ZXTRKU02 where is defined the TABLES IDOC_DATA STRUCTURE EDIDD, I find that all field of the table IDOC_DATA are not set. More exactly my expectation is to find values for SEGNUM, HLEVEL, PSGNUM.
In a few words I need to execute an enhancement, via abap code, of the struscure of the idoc before sending it out since I have a requirement to test this enhancement in my XI environment, receiving as input this ideoc modified.
Then, I need to add a new segment and one child.
Any suggestion will be well appreciated.
Thanks in advance.
Regards,
Giovanni -
How to insert a new line item in VA01/VA02 by using ABAP code?
Hi Gurus
i have a very tough requirement. the customer wants to insert a free goods after an item has been populated in VA01/VA02 automatically according to some certain rules. the input material may be a main material of a sales BOM.
for example. let's suppose there is a material A who has two sub-material B and C which is maintained in a sales BOM via CS01/CS02. when the material A has been input in the line item in VA01/VA02, its quantity input and after the ENTER key has been clicked, another material D may be displayed in a new line as a gift if the condition met. the condition relates to customer/material/quanity and these information are stored in a Z-table.
on the other hand, if the material A is only a single material(not a BOM), the gift(material D) will also be filled automatically if the condition met.
i have already enhance the FM cs_bom_explosion to filfill the requirment for BOM materials. whereas it is very hard to find the enhanment point for the single material.
so my question is where is the correct place for me to insert the ABAP code, which decides whether the gift should be given or not and furthermore inserts the new line item into XVBAP. i tried to use MV45AFZZ, whereas the data is always inconsistant if a new line has been inserted. it is very strange that there is no temperary internal table storing line item data input in the table controal of VA01/VA02. system reads the line item data , line by line, via a system kernal function call.
any hints are welcome. thanksHI Stephen,
I have the same prolem. I modified the 5 global tables, but I don't see the new line in the screen.
Can you help me with some details?
Thx!
Mihaela -
Abap Code TO ENHANCE DATASOURCE with KEY FIELD OF SOURCE TABLE
Dear Friends, Please help me to resolve this important issue at my end.
<b>Requirement</b>: enhance the STRUCTURAL data source which is
based on the table VISTSU , now this table has a <b>key INTERNO</b> (Data Element : SECAINTRENO) which i want to enhance in datasource
SGONR = STRUCTURAL NUMBER present in extract structure of datasource
Solution: I am not able to see any records for zzinterno enhance field in datasource rsa3 (Extractor CHECKER). Can u help me correct the ABAP code or tell me the way to pull the records for ZZINTERNO from VISTSU table.
Thanks
Poonam Roy
ABAP Code
data: l_s_REIS_STRUCTURAL_ATTR like REIS_STRUCTURAL_ATTR.
case i_datasource.
WHEN '0STRUCTURAL_ATTR'.
loop at C_t_data into l_s_REIS_STRUCTURAL_ATTR.
l_tabix = sy-tabix.
clear I_VISTSU .
select single * from VISTSU into i_VISTSU where SG0NR = l_s_REIS_STRUCTURAL_ATTR-SGONR.
if sy-subrc = 0.
l_s_REIS_STRUCTURAL_ATTR-ZZINTRENO = I_VISTSU -INTRENO.
modify C_t_data from l_s_REIS_STRUCTURAL_ATTR index l_tabix.
endif.
endloop.
endcase.Try the below code.
data: l_s_REIS_STRUCTURAL_ATTR like REIS_STRUCTURAL_ATTR.
data: temp_interno like VISTSU -INTRENO.
data: h_tabix LIKE sy-tabix.
case i_datasource.
WHEN '0STRUCTURAL_ATTR'.
loop at C_t_data into l_s_REIS_STRUCTURAL_ATTR.
MOVE SY-TABIX TO H_TABIX.
clear temp_interno.
select single INTERNO from VISTSU into temp_interno where SG0NR = l_s_REIS_STRUCTURAL_ATTR-SGONR.
if sy-subrc = 0.
l_s_REIS_STRUCTURAL_ATTR-ZZINTRENO = temp_interno.
endif.
modify C_t_data from l_s_REIS_STRUCTURAL_ATTR index H_TABIX.
ENDLOOP.
ENDCASE.
Regards, Siva -
ABAP Code for summation of key figure
Hi Guys,
I am new to ABAP and my requirement is as follows-
I have an infocube containing data like
Location Item Amount Month
India TV 10 Jan
India DVD 10 Jan
India XBOX 10 Jan
US TV 10 Jan
US XBOX 15 Jan
US DVD 20 Jan
UK XBOX 30 Jan
UK TV 20 Jan
UK DVD 15 Jan
India TV 20 Feb
US DVD 20 Feb
UK XBOX 10 Feb
India TV 20 Mar
Now by using open hub, I want to extract a file which would display report as -
Output file
15-Oct-2010
Location Item Amount
India TV 50
India DVD 10
India XBOX 10
US TV 10
US DVD 40
US XBOX 15
UK TV 20
UK DVD 15
UK XBOX 40
which means it should sum based on combination of location and item and create one single row.
I need some ABAP code which could be written in expert routine so as to to calculate single rows of amount for all data packets of infocube.
Kindly suggest on how to proceed on it.
Thanks in advance
Moderator Message: Even if you are new-to-ABAP, it does not imply that you can expect others to do your work. If you are a BI consultant, take the help of an ABAP consultant or self-learn the basic concepts of ABAP. If you are an ABAPer, go back to the training center.
Edited by: kishan P on Oct 15, 2010 10:34 AMFollow this white paper .... called, "How to .... Calculate with Attributes":
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/72f4a790-0201-0010-5b89-a42a32223ffc
Brian -
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 -
Hi,
We have requirement to map survey values from flat file.For example I have question which accept multiple values like
Intersted in below products...
Windows
Unix
DOS
If pass these three vaues in flat file, I am not getting any error.However If I pass only one value like windows, keep unix and DOS fields blank, I am getting mapping format error in External list.
Does anyone knows how to configure this scenario? I know we have option in ELM Mapping format to write ABAP code, Can we achieve this using ABAP?
Thanks for your time.
Cheers,
AjayHi Ajay,
It must be because the IDOC is expecting details for all three values.
Better use abap coding to map them.
Best Regards,
Pratik Patel
Maybe you are looking for
-
Am I the ONLY one in the world with this problem!??
before I downloaded twhirl, i upgraded to most current version of Adobe Air (1.5.1) from (1.5.0). It actually occcurred to me that i had never used adobe air before, eventhough i´ve had it installed for ages. i cannot run twhirl-0.9.air because the e
-
Flash player not working on internet explorer 8 cipher strength 128-bit
PLEASE HELP! I'Mm using Windows XP and Internet Explorer 8 with cipher strength 128-bit and Flash player does not work properly, like when I want to watch a music video or listen to music on You Tube it plays then stops and plays and stops continuous
-
Error in XPRAS_UPG Phase for report RSR_VARIANT_XPRA
Upgrade from 4.6C to SAP ERP 2005 SR2 with all support packs During execution of background job for RSR_VARIANT_XPRA, TP terminates with exit code "12" and halts the upgrade process. On manual execution report throws error message Program class RSR_R
-
IPhoto / iTunes Sync Problems
Hi all, not sure if anyone else is having this problem. Since the upgrade to iTunes 10.5 and iOS5 and iPhoto 9.2 and OS X 10.7.2 (phew!), I've had problems with photo synchronisation on my iPad and iPhone. So.... iPhoto reports that it has 2,610 phot
-
Differences between ODI 11.1.1.7 and ODI 11.1.1.6
Hi, Nowadays, I'm working with Oracle Data Integrator 11.1.1.7 and I have to do a downgrade to Oracle Data Integrator 11.1.1.6. So, the problem is that I don't know what are the differences between this two releases. Please, Could anyone help me wit