ABAP-read a single sales line text and feature value bapi

Source: Internet
Author: User

To facilitate the use of SQL to retrieve the order text and feature values, a bapi is provided to retrieve the value and write it into a custom table.

Then, this bapi is called at the exit where the order is saved. In the future, as long as the order changes, the custom table will be automatically updated.

 

 

 

Function zbapi_read_vbapex.

*"----------------------------------------------------------------------

* "Fangkailove@gmail.com

*"

* "*" Local interface:

* "Importing

* "Value (vbeln) type vbeln_va

* "Value (posnr) type posnr_va

* "Value (cuobj) type cuobj

* "Value (autosave) type char1" whether to automatically store data in the table

* "Exporting

* "Value (vbapex) type zsdvbap_ex

*"----------------------------------------------------------------------

 

 

Tables: zsdvbap_ex.

Data: itab_sohead like thead,

Itab_soline like tline occurs 0 with header line.

Data: p_name like THEAD-TDNAME,

P1 like vbeln,

P2 like posnr.

 

Data: TMP type string value ''.

Data: Begin of itmtext,

Itmtxt1 like ZSDVBAP_EX-ITMTXT1,

Itmtxt2 like ZSDVBAP_EX-ITMTXT2,

Itmtxt3 like ZSDVBAP_EX-ITMTXT3,

End of itmtext.

 

Call function 'conversion _ exit_alpha_input'

Exporting

Input = vbeln

Importing

Output = P1.

 

Call function 'conversion _ exit_alpha_input'

Exporting

Input = posnr

Importing

Output = P2.

 

Concatenate P1 P2 into p_name.

 

"ID: 0001 name: sales order + Line Project No. 0000110298000010 object: vbbp

Call function 'read _ text'

Exporting

Id = '000000'

Language = '1'

Name = p_name

Object = 'vbbp'

Importing

Header = itab_sohead

Tables

Lines = itab_soline

Exceptions

Id = 1

Language = 2

Name = 3

Not_found = 4

Object = 5

Reference_check = 6

Wrong_access_to_archive = 7

Others = 8.

Loop at itab_soline.

Concatenate ''tmp itab_soline-tdline into TMP.

Endloop.

If TMP <> ''.

Move TMP to itmtext.

Move-corresponding itmtext to vbapex.

Else.

Call function 'read _ text'

Exporting

Id = '000000'

Language = 'E'

Name = p_name

Object = 'vbbp'

Importing

Header = itab_sohead

Tables

Lines = itab_soline

Exceptions

Id = 1

Language = 2

Name = 3

Not_found = 4

Object = 5

Reference_check = 6

Wrong_access_to_archive = 7

Others = 8.

Loop at itab_soline.

Concatenate ''tmp itab_soline-tdline into TMP.

Endloop.

 

Move TMP to itmtext.

Move-corresponding itmtext to vbapex.

Endif.

 

Clear TMP.

 

 

If cuobj = 0.

Select single cuobj into cuobj from vbap where vbeln = p1 and posnr = P2.

Endif.

 

If cuobj <> 0.

Data: I _configuration like api_value occurs 0 with header line.

Data: stratwtb (50) type C.

Call function 'vc _ I _get_configuration'

Exporting

Instance = cuobj "feature value

Language = sy-Langu

Print_sales = 'X'

Tables

Configuration_idoc = I _configuration

Exceptions

Others = 4.

 

 

Data: idx type I value 1.

Loop at I _configuration.

Case idx.

When 1.

VBAPEX-ATWTB1 = I _configuration-ATWTB.

Concatenate ''I _configuration-ATBEZ into TMP.

When 2.

VBAPEX-ATWTB2 = I _configuration-ATWTB.

Concatenate TMP ',' I _configuration-ATBEZ into TMP.

When 3.

VBAPEX-ATWTB3 = I _configuration-ATWTB.

Concatenate TMP ',' I _configuration-ATBEZ into TMP.

When 4.

VBAPEX-ATWTB4 = I _configuration-ATWTB.

Concatenate TMP ',' I _configuration-ATBEZ into TMP.

When others.

Endcase.

Idx = idx + 1.

Endloop.

Endif.

 

Vbapex-mandt = sy-mandt.

VBAPEX-VBELN = P1.

VBAPEX-POSNR = P2.

VBAPEX-ATDESC = TMP.

 

 

If autosave = 'x '.

Move vbapex to zsdvbap_ex.

Delete from zsdvbap_ex where vbeln = p1 and posnr = P2.

Insert zsdvbap_ex.

Commit work.

Endif.

 

 

 

 

Endfunction.

 

 

 

 

 

 

Bytes --------------------------------------------------------------------------------------------------------------------------

Export call:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.