pub struct SAPComInstance;
Expand description

An instance of a COM session. This should be kept whilst a connection to SAP is used.

Implementations§

source§

impl SAPComInstance

source

pub fn new() -> Result<Self>

Initialise the COM environment.

Examples found in repository?
examples/simple.rs (line 32)
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
fn main() -> Result<()> {
    // Initialise the environment.
    let com_instance = SAPComInstance::new()?;
    eprintln!("Got COM instance");
    let wrapper = com_instance.sap_wrapper()?;
    eprintln!("Got wrapper");
    let engine = wrapper.scripting_engine()?;
    eprintln!("Got scripting engine");
    let connection = engine.get_connection(0)?;
    eprintln!("Got connection");
    let session = connection.children(0)?;
    eprintln!("Got session");
    if let SAPComponent::GuiMainWindow(wnd) = session.find_by_id("wnd[0]")? {
        wnd.maximize().unwrap();

        if let SAPComponent::GuiOkCodeField(tbox_comp) =
            session.find_by_id("wnd[0]/tbar[0]/okcd")?
        {
            tbox_comp.set_text("/nfpl9").unwrap();
            wnd.send_vkey(0).unwrap();
        } else {
            panic!("no ok code field!");
        }
    } else {
        panic!("no window!");
    }

    Ok(())
}
source

pub fn sap_wrapper(&self) -> Result<SAPWrapper>

Create an instance of the SAP wrapper

Examples found in repository?
examples/simple.rs (line 34)
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
fn main() -> Result<()> {
    // Initialise the environment.
    let com_instance = SAPComInstance::new()?;
    eprintln!("Got COM instance");
    let wrapper = com_instance.sap_wrapper()?;
    eprintln!("Got wrapper");
    let engine = wrapper.scripting_engine()?;
    eprintln!("Got scripting engine");
    let connection = engine.get_connection(0)?;
    eprintln!("Got connection");
    let session = connection.children(0)?;
    eprintln!("Got session");
    if let SAPComponent::GuiMainWindow(wnd) = session.find_by_id("wnd[0]")? {
        wnd.maximize().unwrap();

        if let SAPComponent::GuiOkCodeField(tbox_comp) =
            session.find_by_id("wnd[0]/tbar[0]/okcd")?
        {
            tbox_comp.set_text("/nfpl9").unwrap();
            wnd.send_vkey(0).unwrap();
        } else {
            panic!("no ok code field!");
        }
    } else {
        panic!("no window!");
    }

    Ok(())
}

Trait Implementations§

source§

impl Drop for SAPComInstance

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.