Determine length of string without function module
hai experts,
i need to know how to determine length of string without function module strlen'
regards,
karthik
Please SEARCH in SCN before posting.
Similar Messages
-
Sap Script - numbers to words without function module
Moderator message - please use a meaningful subject in future. I've changed it for you this time. Also, moved to the correct forum
Hi Friends,
In SAP Script how to convert numbers into words with out using the function module in the driver program.
examplae 21 kg as twenty one kg.
Please help me to solve this problem.
Thanks in advance.
Gayathri S
Edited by: Matt on Nov 5, 2008 9:15 AMHi,
In the SAP Script, you can call the perform like below:
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/: ENDPERFORM
You can create a separate include or use an existing include related to your script and create the above <form> in that <prog>.
The syntax for creating the form in the include is as below:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
ENDFORM.
Example:
In your script,
/: PERFORM GET_BARCODE IN PROGRAM ABCDE
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
And in the report ABCDE, create the form like this:
REPORT ABCDE.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY 'PAGE'.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'NEXTPAGE'.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY 'BARCODE'.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = '|'. "First page
ELSE.
OUT_PAR-VALUE = '||'. "Next page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Hope this helps.
Regards,
Suganya -
Problem in getting last value of a string in Function Module
Hi,
I am working on FM in which i have to put highfen mark which is working ok,but the problem if there is when the value of string finds a space it should not insert highfen in it and i am not able to put the condition in it as it showing the higfen even when the word is full in the first line.i want to show highfen where the word is not able to display complete. here is d code which i am using right now. plzz provide me guidlines to solve this problem.
here's d code:-
FUNCTION Z_STRING_LENGTH1.
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_STRING) TYPE STRING
*" VALUE(LENGTH) TYPE I
*" EXPORTING
*" VALUE(E_STRING) TYPE STRING
data: STRING_F type string, "Stores the value in string format
STRING_LENGTH type i, "Length of the string
DIFF type i, "Difference among the value
DIFF1 TYPE C,
STRING1 type string, "Stores the 1st String
STRING2 type string, "Stores the 2nd String
STRING3 type string, "Stores the 3rd String
STRING4 type string, "Stores the 3rd String
STRING5 type string, "Stores the 3rd String
LENGTH2 type I.
STRING_F = I_STRING.
STRING_LENGTH = STRLEN( I_STRING ).
DIFF = STRING_LENGTH - LENGTH.
IF DIFF LE 0.
DIFF = 0.
ENDIF.
IF LENGTH LE STRING_LENGTH.
STRING1 = STRING_F(LENGTH).
ELSE.
STRING1 = STRING_F(STRING_LENGTH).
ENDIF.
IF LENGTH LE STRING_LENGTH.
STRING2 = STRING_F+LENGTH(DIFF).
ELSE.
STRING2 = STRING_F+STRING_LENGTH(DIFF).
ENDIF.
length2 = length - 1.
STRING3 = STRING1+length2(1).
STRING4 = STRING2+0(1).
IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
concatenate STRING1 '-' STRING2 into STRING5.
e_string = STRING5.
ELSE.
concatenate STRING1 STRING2 into STRING5.
e_string = STRING5.
ENDIF.
ENDFUNCTION.
Edited by: ricx .s on May 12, 2009 5:20 AMHi,
I checked your code... its working fine except for some cases it is giving dumps for which I have added certain if conditions....
Please check the modified code below... have optimized it as well by removing one extra if condition....
you can copy and paste the code below...
DATA: STRING_F TYPE STRING, "Stores the value in string format
STRING_LENGTH TYPE I, "Length of the string
DIFF TYPE I, "Difference among the value
DIFF1 TYPE C,
STRING1 TYPE STRING, "Stores the 1st String
STRING2 TYPE STRING, "Stores the 2nd String
STRING3 TYPE STRING, "Stores the 3rd String
STRING4 TYPE STRING, "Stores the 3rd String
STRING5 TYPE STRING, "Stores the 3rd String
LENGTH2 TYPE I.
STRING_F = I_STRING.
STRING_LENGTH = STRLEN( I_STRING ).
DIFF = STRING_LENGTH - LENGTH.
IF DIFF LE 0.
DIFF = 0.
ENDIF.
IF LENGTH LE STRING_LENGTH.
STRING1 = STRING_F(LENGTH).
STRING2 = STRING_F+LENGTH(DIFF). " added this statement in this if itself instead of one extra if
" which is not required
ELSE.
STRING1 = STRING_F(STRING_LENGTH).
STRING2 = STRING_F+STRING_LENGTH(DIFF).
ENDIF.
IF LENGTH IS NOT INITIAL.
LENGTH2 = LENGTH - 1.
ENDIF.
" put this if condition as there is a dump occuring at this place.
" Dump occurs when you give the length value as 0
" Say for example the value of I_STRING, I passed it as SIDDARTH
" and the length I passed as 0, then it gives me a dump
STRING3 = STRING1+LENGTH2(1).
IF STRING2 IS NOT INITIAL.
STRING4 = STRING2+0(1).
ENDIF.
" put this if condition as there is a dump occuring at this place.
" Dump occurs when you give the length value greater than or equal to
" the string length
" Say for example the value of I_STRING, I passed it as SIDDARTH
" and the length I passed as 8, then it gives me a dump
IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
CONCATENATE STRING1 '-' STRING2 INTO STRING5.
E_STRING = STRING5.
ELSE.
CONCATENATE STRING1 STRING2 INTO STRING5.
E_STRING = STRING5.
ENDIF. -
In a print statement ie System.out.print(String), how can you ensure that the string will take up a specific number of spaces, for tabulation purposes.
public final static String padRight(String theString, char thePadChar,
int len) {
if(theString.length() >= len)
return(theString);
else
return(theString +
replicate(thePadChar, len - theString.length()));
public final static String replicate(char c, int count) {
StringBuffer sb = new StringBuffer();
for(int i = 0; i < count; i++)
sb.append(c);
return(sb.toString()); -
Function Module Interface for Agent Determination Rule without Tables Param
Hi,
I'm currently trying to create an agent determination rule using a custom function module. I know that the function module must have a certain interface consisting of two table parameters to be accepted by the system.
But since table parameters are obsolete for a few years, what's the solution for this?
As workaround, I just copied an old function module with the right interface but that's not an ideal solution for me.
Did anyone else come across this?
Thanks and regards,
MaxHello,
"I know that the function module must have a certain interface consisting of two table parameters to be accepted by the system."
So, you have to use tables. You can't use tables in a new function, but you can copy one that does.
What sort of "solution" did you have in mind?
regards
Rick Bakker
hanabi technology -
Access function module string from JSP file
Hello,
I an a Java person with very little knowledge of ABAP. I have a Function Module, which returns the String - Y_text with value "X" or "Y". Now, I want to use this "X" or "Y" in my JSP page. And based on the value do some things. Eg:
If (Y_text == "X")
"Value is X"
How do I pick up the valus of Y_text from the function module?
I know how to get the values from Extention Data like below, but this does not seem to be working in case of the String from function module.
String Y_text = (String) userSessionData.getAttribute("Y_text");
Kindly suggest.Hi Shaun,
Check the below link, it discusses about calling function module from ISA. Its a nice beginner's tutorial
by Sateesh. You can copy the code given in ZAction.java in your jsp and get the values from FM.
http://sites.google.com/site/sateeshchandrach2/isa2
Hope this helps you!
Regards,
Arshi -
CALL Function Module RV_CALL_CHANGE_TRANSACTION in a NEW session/window
Hi,
I am modifying report VA14L. When a sales document is clicked on in the ALV grid, I need the sales document to open in a NEW window, not in the same. To determine and open the transaction, function module RV_CALL_CHANGE_TRANSACTION is used. How can I force this FM to open in a new window?
Many Thanks,
JeroenThanks.
I think you mean STARTING NEW TASK instead of IN NEW TASK because the latter does not exist. STARTING NEW TASK '<task>' does not work either, it causes a short dump:
Error analysis
An error occurred when executing a REMOTE FUNCTION CALL.
It was logged under the name "CALL_FUNCTION_NOT_REMOTE"
on the called page.
So any other suggestions? -
Length of a string without using any built-in functions
code that returns the length of a string without using any built-in functions.
thanks
SamA string is internally represented by a character array. An array of characters will reside on the stack, not the heap. Yes, we always learned that String is a reference type, but what goes on in your memory might still surprise you...
A struct is internally represented by only it's private properties, sequentially on the stack.
So basically, what I thought is happening by messing with the structlayout: is only tricking our programming a bit into thinking that the top X bytes on the stack represent a chararray, while actually we put them there as a string.
Wrong. True. And wrong.
A string is internally represented by, in that order, an array length, a string length, the chars. None of them resides on the stack.
An array is internally represented by, in that order, an array length and the chars. None of them resides on the stack.
When you use the FieldOffset attribute to handle the string as a char array, you don't get anything right:
- the Length returned is the "array length" of the string, which is equal to the string length + 1.
- the chars returned by the array indexer are shifted by 2 chars (the length of the "string length" field).
You can use the FieldOffset to make that work, but it needs a little bit more work.
unsafe static int Test()
string myString = "This string may contain many string inside this string";
string testString = "string";
int countResult = 0;
fixed (char* myChars = new StringToChar { str = myString }.chr, testChar = new StringToChar { str = testString }.chr)
// The 2 first chars of the array are actually the string length.
int myCharsLength = myChars[1] << 16 | myChars[0];
int testCharLength = testChar[1] << 16 | testChar[0];
for (int i = 0; i < myCharsLength - testCharLength + 1; i++)
if (myChars[i + 2] == testChar[2])
for (int j = 1; j < testCharLength; j++)
var c = testChar[7];
if (myChars[i + 2 + j] != testChar[j + 2])
goto endOfCharAnalyses;
countResult++;
endOfCharAnalyses:
continue;
return countResult; -
Function Module GUI_DOWNLOAD: Type String Issue
I am working in 4.6C. I have used this Function Module many times in the past without issue, but not at this site. It abends and gives me the error message:
The call to the function module "GUI_DOWNLOAD" is incorrect:
The function module interface allows you to specify only fields
of a particular type under "FILENAME". The field "FNAME" specified here
has a different field type.
Here is the field declaration in the code:
PARAMETER: fname type rlgrap-filename DEFAULT 'C:/New_PO_Format.xls'.
The import parameter in GUI_DOWNLOAD for FILENAME is type STRING. When I double click on STRING in the FM I get "Unable to find a tool to process request". And, TYPE STRING does not exist in the system? I started making a Z version of GUI_DOWNLOAD, but it started giving me headaches because I had to start copying other SAP function modules.
Am I missing something? Or, is there a new and improved version of GUI_DOWNLOAD to use?data : v_file type string.
PARAMETER: fname type rlgrap-filename DEFAULT 'C:/New_PO_Format.xls'.
start-of-selection.
v_file = fname.
use v_file in gui_download parameter.
Thanks
Seshu -
Sending String Data of 64 kilo bytes to Remote Function Module
Hi,
I have an RFC call from JAVA and I need to send string data to the FM. The maximum size of the data that I can send from java is 64 kilo bytes (Functional requirement). I want to receive this data as a table's parameter in the FM. Table's parameters data type can only be structure's which are FLAT-LINED. So if I use STRNIG as the data type for receiving the data from JAVA the RFC doesnt allow me (As this makes the structure NON FLAT LINED which RFC will not allow as data type for tables parameter). So I have to use some other data type like CHAR or LCHR. But the maximum size for CHAR and LCHR is around 32 kilo bytes. I need a way to receive 64 kilo bytes of data into the Function Module as a tables parameter.
Thanks in advance
SeshHi!
I think I was pretty near your problem. When talking about table fields, you could a 'parameter' -> field of your table parameter.
Which type? String is out of question, because here length is variable, but you need a constant length definition. I just have a look into help of data, built in ABAP-types. Here C and N can have a length from 1 to 65535 - OK, not 64 KB but only 1 byte missing...
... just made a small test, there is a second border (for non-unicode systems): the total length of the structure can't exceed 65535. If you need additional fields, define a second table parameter and place your additional fields in a second table. You can't define a link field (would need some space), so you have to go for a '1st line of data matches 1st line of attributes'-definition.
I'm still a little bit curious: what kind of data you are sending?
Regards,
Christian -
Error while determining the form function module
Hi everyone,
We are experiencing problems while displaying one adobe form in ESS. Its the Travel Expense form (PTRV_EXPENSE_FORM). When pressing the button to Display/Print the form we get an error message: "Error while determining the form function module", and no form I shown. The ADS server is configured correctly and there are other forms that are actually working, for example the Travel Request form. We are running WAS 7.0 with SP12.
Anyone has an idea what can cause the problem? Any help is greatly appreciated.
Thanks in advance!
Regards,
SophieViktor,
Thank you for your answer, it solved our problem!
Regards,
Sophie -
Need a function module to convert xstring to string in web dynpro applicati
hi,
need a function module to convert xstring to string in web dynpro application other than HR_KR_XSTRING_TO_STRING.
Moderator message: please (re)search yourself first.
Edited by: Thomas Zloch on Nov 17, 2010 5:31 PMHi,
Check the following link:
FM to convert XString to String
Regards,
Bhaskar -
Type conflict when calling a function module (field length)
Dear All,
I am getting this following error while executing: Type conflict when calling a function module (field length)
This is piece of coding i have writern in my action button.
method SEARCH_MATERIAL .
data:
node_mat_input TYPE REF TO if_wd_context_node,
node_mat_output TYPE REF TO if_wd_context_node,
material TYPE BAPIMATDET-MATERIAL,
itab TYPE TABLE OF BAPIMATDOA.
node_mat_input = wd_context->get_child_node( 'NODE_MAT_INPUT' ).
node_mat_output = wd_context->get_child_node( 'NODE_MAT_OUTPUT' ).
node_mat_input->get_attribute( EXPORTING name = 'MATERIAL'
IMPORTING value = material ).
CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
EXPORTING
material = material
PLANT = plant
VALUATIONAREA =
VALUATIONTYPE =
MATERIAL_EVG =
IMPORTING
MATERIAL_GENERAL_DATA = itab
RETURN =
MATERIALPLANTDATA =
MATERIALVALUATIONDATA =
node_mat_output->bind_table( itab ).
endmethod.
Attributes are:
Node name = INPUT its structure is BAPIMATDET
INPUT attributes = MATERIAL of type BAPIMATDET-MATERIAL
Thanks,
Gopi.Hi Amit,
I have used service call to fetch records from that bapi..
The following is the code generated by service call:-
METHOD execute_bapi_material_get_deta .
declarations for context navigation
DATA:
node_bapi_material_get_de TYPE REF TO if_wd_context_node,
node_exporting TYPE REF TO if_wd_context_node,
node_material_general_dat TYPE REF TO if_wd_context_node,
node_importing TYPE REF TO if_wd_context_node,
lri_element TYPE REF TO if_wd_context_element.
declarations for fuba parameters
data:
stru_c_material_general_dat TYPE if_componentcontroller=>element_material_general_dat.
DATA:
attr_material TYPE bapimatdet-material,
attr_plant TYPE bapimatall-plant.
get all involved child nodes
node_bapi_material_get_de = wd_context->get_child_node( `BAPI_MATERIAL_GET_DE` ).
node_exporting = node_bapi_material_get_de->get_child_node( `EXPORTING` ).
node_material_general_dat = node_exporting->get_child_node( `MATERIAL_GENERAL_DAT` ).
node_importing = node_bapi_material_get_de->get_child_node( `IMPORTING` ).
get input from context
node_importing->get_attribute( EXPORTING name = `MATERIAL`
IMPORTING value = attr_material ).
node_importing->get_attribute( EXPORTING name = `PLANT`
IMPORTING value = attr_plant ).
the invocation - errors are always fatal !!!
CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
EXPORTING
material = attr_material
plant = attr_plant
" valuationarea = wd_This->Valuationarea
" valuationtype = wd_This->Valuationtype
" material_Evg = wd_This->Material_Evg
IMPORTING
material_general_data = stru_c_material_general_dat
" return = wd_This->Return
" materialplantdata = wd_This->Materialplantdata
" materialvaluationdata = wd_This->Materialvaluationdat
node_material_general_dat->bind_structure( stru_c_material_general_dat[] ).
ENDMETHOD.
but the problem is I am getting the following error while compiling...
" stru_c_materialplantdata " is not an internal table - the " OCCOURS n" specification is missing.
Thanks,
Gopi.
Edited by: Yegalaivan on Nov 18, 2009 8:30 AM -
Functional Module for Free Goods Determination
Dear Experts,
What is the standard Functional module used to determine Free goods in sales order creation.
Thanks & Regards
ParvizHi Moazzam,
Found that standard Functional Module for Determine Free goods is "NATRAB_SELECTION".
Thanks for replay, Closing the issue.
Regards
Parviz. -
RFC function module without RETURN parameter thows error in XI. Please help
Hi Experts,
I have a File to RFC scenario in XI. The RFC function module that I am using at the receiving end does not have "RETURN" parameter. So when I test my scenario I get "RETURN" parameter not found error on SXMB_MONI.
So is it mandatory that RFC function module must have RETURN parameter when used in XI?
Is there any work around to avoid the error without changing the RFC function module?
Please help!
Thanks
GopalIn my senario the QOS is best effort because it is a Sync.
But the function module is sync in nature as it is returning a parameter called SO_Docs and Ret_Msg. The Ret_Msg contains the error info but it not of BAPIRET2 type.
So is there any way to avoid this error when my QOS is best effort?
Please help!
Gopal
Maybe you are looking for
-
Can't transfer a slo-mo video from iPhone 6 to PC
I love my iPhone 6, but it has some quirks. Here is one of them. The slo-mo feature is amazing at 240 frames per second. However, it is not good if I can only view the show motion video on the phone itself. I have tried iCloud, Verizon Cloud, and
-
About HTML and CSS styles in the Contribute Style menu
This question was posted in response to the following article: http://help.adobe.com/en_US/contribute/using/WS5b3ccc516d4fbf351e63e3d1180fba3730-7e6cCS5. html
-
Please, I'm experiencing difficulties downloading and syncing apps to my iDevice
When downloading over the wifi on the iDevice, its shows 'waiting' and I have no other app downloading and also if I want to sync, the app will be inactive after syncing. Can someone please help
-
IPM 11g Picklist based on database lookup
Is there a way with IPM 11g to create a picklist based on a database lookup? If so how?
-
Hi. I have just purchased a new C2-03, installed two sims, and all works perfectly. I have calls, sms and mms on Sim1, and data on Sim2. But this works only when I make a Gprs connection via the phone. If I try to connect my laptop via bluetooth to u