Application Development 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: 

How to upload long text using BAPI_SERVICE_CREATE

Former Member
0 Kudos

Hi,

I'm uploading service master records (transaction AC03) through my program using function BAPI_SERVICE_CREATE. As per the requirements, for each service number, I've to pass long text also (refer to the last text area on the transaction screen).

In the tables section of the bapi BAPI_SERVICE_CREATE, there is a provision for an internal table on the form SERVICE_LONG_TEXTS. But it is of no use as even if I pass data to it, it is not written to the database.

Can anyone tell me solution for my problem?

Thanks.

Anuj.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Thanks MD and Krishna.

Let me explain the finer details of the program logic.

I'm uploading service master records from an excel sheet. Now service numbers can be externally provided or internally generated.

Currently, I am passing the records using BAPI_SERVICE_CREATE and the long text using CREATE_TEXT. The problem is that create_text takes service number as an input and for service numbers created using internal number range, its practically not feasible to retreive the created number during the program execution itself, to be further used in create_text.

So I hope Krishna you must have understood that your solution is good, but in my case, it is not feasible. This you can check from the transaction text area properties itself.

MD, as you have asked for the values I'm passing, so here they are:

SERVICE_LONG_TEXTS-LANGUAGE : 'E'

*SERVICE_LONG_TEXTS-LANGUAGE_ISO

*SERVICE_LONG_TEXTS-FORMAT

SERVICE_LONG_TEXTS-LINE : Any long text

SERVICE_LONG_TEXTSCHANGE_ID : 'X'

My only hope is that using the SERVICE_LONG_TEXTS I may be able to pass data. But it is not happening for my test cases.

Thanks and Regards,

Anuj.

9 REPLIES 9

Former Member
0 Kudos

Hi Anuj

What are the values you are passing for following in the BAPI

Regards

MD

SERVICE_LONG_TEXTS-LANGUAGE

SERVICE_LONG_TEXTS-LANGUAGE_ISO

SERVICE_LONG_TEXTS-FORMAT

SERVICE_LONG_TEXTS-LINE

SERVICE_LONG_TEXTSCHANGE_ID

Former Member
0 Kudos

Usuall for long text you may have to explicitly call SAVE_TEXt upon successfull completion of BAPI. Something like shown below

call function 'SAVE_TEXT'

EXPORTING

header = s_thead

insert = 'X'

TABLES

lines = tlines

EXCEPTIONS

others = 1.

if sy-subrc = 0.

call function 'COMMIT_TEXT'

EXPORTING

savemode_direct = 'X'.

endif.

Former Member
0 Kudos

Thanks MD and Krishna.

Let me explain the finer details of the program logic.

I'm uploading service master records from an excel sheet. Now service numbers can be externally provided or internally generated.

Currently, I am passing the records using BAPI_SERVICE_CREATE and the long text using CREATE_TEXT. The problem is that create_text takes service number as an input and for service numbers created using internal number range, its practically not feasible to retreive the created number during the program execution itself, to be further used in create_text.

So I hope Krishna you must have understood that your solution is good, but in my case, it is not feasible. This you can check from the transaction text area properties itself.

MD, as you have asked for the values I'm passing, so here they are:

SERVICE_LONG_TEXTS-LANGUAGE : 'E'

*SERVICE_LONG_TEXTS-LANGUAGE_ISO

*SERVICE_LONG_TEXTS-FORMAT

SERVICE_LONG_TEXTS-LINE : Any long text

SERVICE_LONG_TEXTSCHANGE_ID : 'X'

My only hope is that using the SERVICE_LONG_TEXTS I may be able to pass data. But it is not happening for my test cases.

Thanks and Regards,

Anuj.

0 Kudos

Doesn't the BAPI_SERVICE_CREATE return the Service number in the exporting parameter SERVICE?. If so you can pass this number on to CREATE_TEXT.

Otherwise you can you can read from the SM tables using some search criteria to read the Service that just got created.

0 Kudos

Thanks Krishna for your reply.

Actually I had not given a thought to the exporting parameter of the function. So your suggestion raised my hopes.

But to tell you the truth, it did not work as you had said. I passed the service number returned by the function bapi_service_create to create_text, but the long text is not being stored.

To be sure, I even used the conversion routine CONVERSION_EXIT_ALPHA_OUTPUT to remove the extra zeroes before the service number, but even that did not work.

Thanks,

Anuj.

0 Kudos

Can you post the code where you are calling the Create_text or Save_text please?

0 Kudos

Hi Krishna,

As you required, I'm posting here the relevant lines of my code and data declarations as well.

-


DATA:

C_FOBJECT(10) TYPE C VALUE 'ASMD',

C_FID(4) TYPE C VALUE 'LTXT',

L_PASS_SPRAS TYPE BAPISRV_ASMD-MASTER_LANGU,

L_FNAME TYPE THEAD-TDNAME,

L_SERVICE_RET TYPE BAPISRV_ASMD-SERVICE.

L_PASS_SPRAS = 'E'.

CALL FUNCTION 'BAPI_SERVICE_CREATE'

EXPORTING

IM_SERVICE_DATA = L_SERVICE_DATA

IM_SERVICE_DATAX = L_SERVICE_DATAX

IMPORTING

SERVICE = L_SERVICE_RET

TABLES

RETURN = IT_RET

SERVICE_DESCRIPTION = IT_SERV_DESC.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

L_FNAME = L_SERVICE_RET.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

FID = C_FID

FLANGUAGE = L_PASS_SPRAS

FNAME = L_FNAME

FOBJECT = C_FOBJECT

TABLES

FLINES = IT_LONG_TEXT

-


I had also used the conversion routine CONVERSION_EXIT_ALPHA_OUTPUT for converting L_SERVICE_RET but here I've not added those lines, for the sake of simplicity.

Thanks and Regards,

Anuj.

0 Kudos

Anuj,

Create a new program using the following code and run it using an existing service number to see if the longtext gets updated. I ran it in my system and it is working fine. If it works for you, then you can modify your code accordingly.

report zlongtext.

data: header like thead,

ilines like tline occurs 0 with header line.

parameters: asnum like asmd-asnum.

start-of-selection.

header-tdobject = 'ASMD'.

header-tdname = asnum. " Make sure it has leading zeroes.

header-tdid = 'LTXT'.

header-tdspras = sy-langu.

ilines-tdformat = '*'.

ilines-tdline = 'Just a test to see how it works'.

append ilines.

clear ilines.

call function 'SAVE_TEXT'

exporting

header = header

  • INSERT = ' '

savemode_direct = 'X'

tables

lines = ilines

exceptions

id = 1

language = 2

name = 3

object = 4

others = 5.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

call function 'COMMIT_TEXT'.

if sy-subrc = 0.

write: / 'updated successfully'.

endif.

endif.

0 Kudos

Thanks Krishna for all the help and patience.

The problem is resolved and SAVE_TEXT is giving the desired performance.

BTW, I'm still not sure why CREATE_TEXT was not saving the long text, since in both functions, we are passing exactly the same values!!

Best Regards,

Anuj