Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

retreving data from sapscript

Former Member
0 Likes
592

Hi Experts,

Iam working on sap scripts.

I have BUKRS in my variable /: &MSEG-BUKRS&.

Using this value i want to extract BUTXT from t001 table.

Since my print program is sap standard program i can not write select statement.

How can i get BUTXT value into my sapscript.

Thanks

kaki

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
564

You can use a PERFORM statement in your sapscript to retrieve the text and pass back to the sapscript.

REgards,

Rich Heilman

Read only

0 Likes
564

Hi,

Could you please give me any sample code using perform statement to retreive BUTXT value.My code is like this..


/: DEFINE &ZBUKRS& = &MSEG-BUKRS&
/: PERFORM GET_COMP_NAME IN PROGRAM 
/: test
/: USING &ZBUKRS& CHANGING &ZBUTXT&
/: ENDPERFORM


REPORT  test.

FORM get_comp_name TABLES in_tab  STRUCTURE itcsy
                         out_tab STRUCTURE itcsy.

 BREAK-POINT.
  DATA: lv_zbukr LIKE t001-bukrs,
        lv_butxt LIKE t001-butxt.

  READ TABLE in_tab WITH KEY 'ZBUKRS'.
  lv_zbukr = in_tab-value.

  SELECT SINGLE butxt INTO lv_butxt FROM
  t001 WHERE bukrs = lv_zbukr.

  READ TABLE out_tab WITH KEY 'ZBUTXT'.
  IF sy-subrc = 0.
    out_tab-value = lv_butxt.
    MODIFY out_tab INDEX sy-tabix.
  ENDIF.            "check for sy-subrc

ENDFORM.                    "comp_reg_num

Is it correct approach??

Read only

0 Likes
564

I believe this is perfect.... you could change all references of &ZBUTXT& to &MSEG-BUKRS& but it should work either way.

Read only

0 Likes
564

Hi Neil,

There is a value in &ZBUKRS&.

But iam not getting company name in &ZBUTXT&.

Where iam doing wrong?

Thanks

kaki

Read only

0 Likes
564

Hi Kaki,

I think you need to put an endperform in after the 'changing' line and put the 'using' and 'changing' parameters on separate lines:

/: DEFINE &ZBUKRS& = &MSEG-BUKRS&

/: PERFORM GET_COMP_NAME IN PROGRAM test

/: USING &ZBUKRS&

/: CHANGING &ZBUTXT&

/: ENDPERFORM