How to cast in ABAP ?
Hi,
I need to cast a data but i don't kow how to do it in ABAP.
Actually, I have a variable typed QUAN (quantity i guess) and i want to concatenate it in a String variable. That's not possible.
The solution i've found is to move the Quan variable to a temporary String variable. I think that's a kind of implicit casting.
Then, including this temporary string variable in the Concatenate instruction is possible.
My question is :
Can I directly cast this data instead of using a temporary variable ?
In Java or VB.NET langauges, we can cast variable like that
(String)my_variable
How to do it in ABAP ?
Thanks
hi,
You got to use the temporary variable of char type as shown below.
data : v_quant type netpr value '1000.00',
v_char(10).
move v_qunat to v_char.
Regards,
Santosh
Similar Messages
-
How to cast an Object into a specific type (Integer/String) at runtime
Problem:
How to cast an Object into a specific type (Integer/String) at runtime, where type is not known at compile time.
Example:
public class TestCode {
public static Object func1()
Integer i = new Integer(10); //or String str = new String("abc");
Object temp= i; //or Object temp= str;
return temp;
public static void func2(Integer param1)
//Performing some stuff
public static void main(String args[])
Object obj = func1();
//cast obj into Integer at run time
func2(Integer);
Description:
In example, func1() will be called first which will return an object. Returned object refer to an Integer object or an String object. Now at run time, I want to cast this object to the class its referring to (Integer or String).
For e.g., if returned object is referring to Integer then cast that object into Integer and call func2() by passing Integer object.GDS123 wrote:
Problem:
How to cast an Object into a specific type (Integer/String) at runtime, where type is not known at compile time.
There is only one way to have an object of an unknown type at compile time. That is to create the object's class at runtime using a classloader. Typically a URLClassloader.
Look into
Class.ForName(String) -
How To Guide on ABAP mapping (How to Use ABAP-Mapping in XI 3.0).
Hi,
I am looking for this document: How To Guide on ABAP mapping (How to Use ABAP-Mapping in XI 3.0), and not able to find it.
Can anybody please point me the location, to look for, or post the document.
Thanks,
NamadevHi Namadev Chillal ,
These r the links containing PDF docs which u r looking for:
how to create a flat file out of an IDoc-XML by means of an ABAP mapping program and the J2EE File Adapter.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a
Excellent PDF Document on Mapping
http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf
Mapping Development with the ABAP Workbench
http://help.sap.com/saphelp_nw04/helpdata/en/10/5abb2d9df242f6a62e22e027a6c382/content.htm
ABAP Mappings
http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm -
Hi All How to TypeCast in vector<>... typedef struct ... to class...
//how to cast the vector to vector cast with out using loop
// is there any way?
//================ This is Type Definition for the class of ClsMytype=====================
typedef struct tagClsMytype
CString m_Name;
int m_Index;
double m_Value;
} xClsMytype;
//================ End of Type Definition for the class of ClsMytype=====================
class ClsMytype : public CObject
public:
ClsMytype(); // Constructor
virtual ~ClsMytype(); // Distructor
ClsMytype(const ClsMytype &e);//Copy Constructor
// =========================================
DECLARE_SERIAL(ClsMytype)
virtual void Serialize(CArchive& ar); /// Serialize
ClsMytype& operator=( const ClsMytype &e); //= operator for class
xClsMytype GetType(); // return the typedef struct of an object
ClsMytype& operator=( const xClsMytype &e);// = operator to use typedef struct
ClsMytype* operator->() { return this;};
operator ClsMytype*() { return this; };
//public veriable decleare
public:
CString m_Name;
int m_Index;
double m_Value;
typedef struct tagClsMyTypeCollection
vector <xClsMytype> m_t_Col;
} xClsMyTypeCollection;
class ClsMyTypeCollection : public CObject
public:
ClsMyTypeCollection(); // Constructor
virtual ~ClsMyTypeCollection(); // Distructor
ClsMyTypeCollection(const ClsMyTypeCollection &e);//Copy Constructor
DECLARE_SERIAL(ClsMyTypeCollection)
virtual void Serialize(CArchive& ar);
xClsMyTypeCollection GetType();
ClsMyTypeCollection& operator=( const xClsMyTypeCollection &e);
ClsMyTypeCollection& operator=( const ClsMyTypeCollection &e); //= operator for class
void Init(); // init all object
CString ToString(); // to convert value to string for the display or message proposed
ClsMyTypeCollection* operator->() { return this;}; // operator pointer to ->
operator ClsMyTypeCollection*() {return this;};
public:
vector <ClsMytype> m_t_Col;
//private veriable decleare
private:
//===================================================
ClsMytype& ClsMytype::operator=( const xClsMytype &e )
this->m_Name= e.m_Name;
this->m_Index= e.m_Index;
this->m_Value= e.m_Value;
return (*this);
//==========================Problem for the vector to vector cast
ClsMyTypeCollection& ClsMyTypeCollection::operator=( const xClsMyTypeCollection &e )
this->m_t_Col= (vector<ClsMytype>)e.m_t_Col; // how to cast
return (*this);
Thanks in AdvanceHi Smirt
You could do:
ClsMyTypeCollection* operator->() {
returnthis;};
// operator pointer to ->
operatorClsMyTypeCollection*()
{returnthis;};
public:
vector<ClsMytype>
m_t_Col;//??
The last line with "vector<xClsMytype>
m_t_Col;". It compiles but I doubt that is what you want.
Regards
Chong -
How to list the abap programs order by updated date in ECD
Hi experts,
how to list the abap programs order by updated date in ECD?
thanks.I wrote a custom program for displaying Z* development work into an ALV report. 2500 character limit prevents me from posting, message me your email and I'll send you source code.
Edited by: Brad Gorlicki on Feb 18, 2010 11:25 PM -
How to call the abap program in workflow
HI Exeprts,
I need to call one abap program in workflow.
can any tell me how to call the abap program in workflow.
thanks ®ards
rameshDear Ramesh,
U can use REPORT business object.
Method : EXECUTE_2
Regards,
Sagar -
How to call an abap report in BSP..
hi all,
Please can anybody tell me how to call an abap report in BSP application.....since I am new to BSP....
with regards,
Santoshcheck this thread
Urgent!! How to call a custom transaction or an ABAP program in BSP? -
How to use webdynpro abap? need any separate software? if no, please help me with Transaction Codes..
Thanks in Advance
-Parthi
Moderator message: please search for available information/documentation.
Edited by: Thomas Zloch on Oct 19, 2011 8:18 PMI don't think you quite understand how hibernation mode works.
"The state of a computer is stored into its main memory, which is also called RAM. When a
computer is powered off, the contents of this memory are irremediably wiped out. Hiberna-
tion works in the following way: before being powered off, the computer saves all the con-
tents of the memory to a file on the hard disk drive. On wake up, data stored in this file is
read out and restored to the memory. Therefore, the RAM contents are the same before
and after the hibernation process, and the state of the computer is also the same. The
saved file is named sleepimage, and is located in the /private/var/vm directory. Hi-
bernation is sometimes also called “software suspend” or “suspend to disk”.
The default suspension feature of Mac OS X, called sleep works in a different way. When
entering sleep, every subsystem of the computer is shut down, except the main memory
which is still powered. This process preserves the contents of the memory, and allows the
computer to wake up quickly. However, a sleeping computer still consumes a small
amount of power. Sleep is sometimes also called “hardware suspend” or “suspend to
RAM”.
Apple introduced the safe sleep feature in Mac OS X 10.4.3 for the Powerbook HD line of
laptops. This feature is a variation of the default suspension behavior. The main memory is
still powered during the sleep, but the contents of the memory are also saved to the disk at
the beginning of the operation. The saved file will only be used if the laptop runs out of bat-
tery power while sleeping, in order to restore the original state of the computer.
This safe sleep feature is what makes hibernation possible in Mac OS X 10.4.3 and above."
Quoted from *Deep Sleep v. 0.7 documentation*
Matthieu Beaumel, 10/03/2006 -
How to debug a ABAP Routine which is in Infopackage Data selection Tab
Hi ,
Please let me know How to debug a ABAP Routine which is in Infopackage Data selection Tab.Hi,
You can try to create infinite loop:
DATA: STOP.
WHILE STOP IS INITIAL. ENDWHILE.
Start InfoPackage and then go to SM50 and swich on debugging for your process. Then in debugger you can change value of STOP variable to skip the loop.
Krzys -
How to create a abap proxy in sproxy netweaver 7.01
sproxy of nw 7.01 is completely different from previous version.For example in prev. versions there is message interface (inbound) (outbound) ...
but in 7.01 , i cannot find how to create an abap proxy class , there is only display proxy in context menu in all segments.(like service interface)
how can i create proxy ?
thanks a lotIn help sap.con says that
Expand the Service Interfaces node.
Select the outbound service interface.
Open the context menu and choose Create.
but there is no outbound service interface under service interface node
what can i do?
thanks a lot.. -
How to cast an object in JSF?
I am working on a travel application. A user can have several bookings and a booking can have several components. A component can be either air or hotel. I want to list the user's bookings on the client using JSF datatable.
<h:dataTable var="component" value="#{booking.components}">
Now depending upon the class of component I need to present different information.
My question is how to cast the variable in JSF ?
ThanksYou can use the String value of Object#getClass()#getName() to lookup the classname and evaluate it in the 'rendered' attribute.
Basic example:
package mypackage;
public class Animal {}
package mypackage;
public class Cat extends Animal {}
package mypackage;
public class Dog extends Animal {}
package mypackage;
public class Fish extends Animal {}MyBeanpublic List<Animal> getList() {
List<Animal> animals = new ArrayList<Animal>();
animals.add(new Dog());
animals.add(new Cat());
animals.add(new Fish());
return animals;
}JSF<h:dataTable value="#{myBean.list}" var="item">
<h:column>
<h:outputText value="It's a Cat" rendered="#{item.class.name == 'mypackage.Cat'}" />
<h:outputText value="It's a Dog" rendered="#{item.class.name == 'mypackage.Dog'}" />
<h:outputText value="It's a Fish" rendered="#{item.class.name == 'mypackage.Fish'}" />
</h:column>
</h:dataTable>As far there is no way to cast objects in JSF.
Edit
If you find it useful, move the classname request to the superclass:
public class Animal {
public String getType() {
String className = getClass().getName();
return className.substring(className.lastIndexOf('.') + 1);
}Which makes life easier without struggling with package names:<h:outputText value="It's a Cat" rendered="#{item.type == 'Cat'}" />
<h:outputText value="It's a Dog" rendered="#{item.type == 'Dog'}" />
<h:outputText value="It's a Fish" rendered="#{item.type == 'Fish'}" />Message was edited by:
BalusC -
How to implement an abap program in a process chain
Hi,
I have an ABAP Program which uploads data into a table.
Now I want to implement this abap program in a process chain.
Please could anyone tell me how this can be done.
Thanks & Regards,
Sushanth H.S.Hi,
A process chain is a background task for processing data into a BW instance .
I want to know how to integrate an abap program into the process chain.
Regards,
Sushanth H.S. -
How to convert following ABAP routine into Java
Hi Experts
I m new to IPC
How to convert following ABAP routine int java
READ TABLE XKOMV INTO XKOMV_AUX WITH KEY
KSCHL = 'ZCU2'
KPOSN = komp-kposn.
IF SY-SUBRC EQ 0.
MOVE XKOMV_AUX-KWERT TO XKWERT.
MOVE XKOMV_AUX-KBETR TO XKOMV-KBETR.
w_kwert = xkomv_aux-kwert * -1.
DO any one has documentation on convertion of abap routines into java
Thanks & Regards
SowmyaHi sowmya,
download this document through this u can solveur problem
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/107adc1a-0501-0010-de8e-973e0fb4049b
Reward if helps
Regards
Manohar -
How to shedule an abap report to run paralely in more background session
I wander how to shedule an abap report to run paralely in more background session.
I am afraid of parallel locking.Hi,
You can schedule different jobs with same program name.
Use ENQUEUE_ & DEQUEUE_ to lock/unlock the records being process. The lock objects can be created in SE11.
Best regards,
Prashant -
How to call a abap program ?
Can anyone tell me how to call one abap program in another abap program ??
Hi,
You can use <b>submit</b> statement to achieve the same.
Sample Code
REPORT ZREP2 NO STANDARD PAGE HEADING.
tables: qals.
RANGES seltab for qals-prueflos.
WRITE: 'Select a Selection!',
SKIP.
FORMAT HOTSPOT COLOR 5 INVERSE ON.
WRITE: 'Selection 1',
/ 'Selection 2'.
AT LINE-SELECTION.
CASE SY-LILLI.
WHEN 4.
SUBMIT zrep1 VIA SELECTION-SCREEN
WITH PARAMET EQ 'Selection 1'
WITH SELECTO IN SELTAB
WITH SELECTO NE 3
AND RETURN.
WHEN 5.
SUBMIT zrep1 VIA SELECTION-SCREEN
WITH PARAMET EQ 'Selection 1'
AND RETURN.
ENDCASE.
Message was edited by: Jayanthi Jayaraman
Maybe you are looking for
-
Palm m125 stylus won't work after hot sync
Yesterday I dropped my m125 and the batteries fell out. I didn't notice right away and the system did a hard reset. When I put the m125 in the cradle and did a hot sync, it updated everything and then I got a message I needed to reset the palm. When
-
Error:MAPPING RESOURCE_NOT_FOUND
Hi Experts, I have a scenario from RFC TO SOAP,it runs fine but rarely I get an error *"MAPPING">RESOURCE_NOT_FOUND*.Not sure what is causing this problem.Can you help me with this guys <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> - <!--
-
IPad w/Retina WIFI + Cellular
I purchased a ipad w/retina wifi + cellular to use in Grenada for school. I also purchased the data plan for Verizon. I replaced the sim chip with one from Grenada and still unable to connect. Please help!
-
I think my mobo died....
;( Well here's the lowdown, System specs: Antec 400W P/S MSI KT4VL mobo AMD 2200+ 1024 MB 333DDR Crucial Ram 80 GB W.D. hd 40/24/40 Lite-On CDRW 16X Piece of Junk DVD cave-man edition magnetic disk reader (floppy...) ATI too-expensive Radeon 9700 Pr
-
I purchased an original Logic academic version, But now after the 9.1.3 upgrade it is rejecting my license key!!! Any help!!