Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all 3125 articles
Browse latest View live

Re: LSMW for CS02 BOM change

$
0
0

Hello,


RCSBI020 option for Mass change/Add item in BoM's off course deletes old items from the BoM and add only the new one.. So adding all the component in Text.File is not an option at all (specifically if you many BoM's to update)...


On the other hand Recording options may be working well for adding new component, BUT doesn't give option to add Document number OR Text Line Option... I have currently similar issue..


Does anyone have any solution..?  how to mass update BOM's (adding new Document number / Text line) either LSMW or something else ?


Thank you in advance..  


If the tr gives return code 8, will all objects except missing objects be imported in PRD?

$
0
0

I imported a tr in ECP/Prd. and it resulted in return code 8 in ECD/Dev.

I checked the logs and found error while generation of program screens.

Two objects were missing and I corrected/included just those 2 objects in a separate tr and imported in ECP.

 

Is it correct? Will my previous objects be present in ECP?

Will all the objects in a TR excepts error objects be transported to ECP if return code is 8 (or) no objects gets imported if return code is 8?

 

 

Please explain.

 

Thanks & Regards,

Sudha.

Re: BAPI for IW61 - Historical maintenance work orders

$
0
0

Was there ever a solution to this? I have the same business needs currently.

Re: Uploading PM historical work orders data through IW61.

$
0
0

Shabbeer, were you able to find a solution for this issue? I am in the same business need right now.

 

thanks,

 

Jacob

Re: How to create OutboundDelivery and set shipping condition (VSBED)

$
0
0

Hello,

As per my understanding delivery is taking VSBED from sales order.

 

You can use USEREXIT_SAVE_DOCUMENT_PREPARE" of include MV50AFZ1 to change VSBED based on your custom logic.

 

You can also refer SAP note 0000415716 which contain details about various exits available during delivery processing and choose the correct exist accordingly.

How to increase the duration of trace in SRT_UTIL

$
0
0

Hi all ,

How to increase the duration of the payload trace in SRT_UTIL .

TRACE.PNG

 

Thanks ,

Sakthikrishnan S .

Re: Multiple idocs in Single Job behaves differently (RBDAPP01)

$
0
0

Hi Asit,

 

We are running into the same issue. Can you please let us know the solution you applied for this problem?

 

Regards,

Manohar Dubbaka.

Re: How to increase the duration of trace in SRT_UTIL

$
0
0

Hi,

 

Please refer the below help page

 

link - Configuring Logging - ABAP Web Services - SAP Library

 

Procedure

  1. Start transaction SRT_UTIL.
  2. Choose the Error Log button.
  3. Choose Start of the navigation pathError LogNext navigation stepGlobal ConfigurationEnd of the navigation path.
  4. Select one of the following levels for logging:
    • Use Inactive to witch off error logging.
    • Use System when you want the system to log only system errors.
    • Use System & Application when you want the system to log system errors and application exceptions.

    CautionSetting the log level to Inactive leaves you without any data for analysis if an error occurs.

  5. Enter the number of days for which the error log keeps the logging entries.The default number of days is 14 days, and can be configured for each SAP client of an ABAP system. Moreover, each log entry can be set to another expiry day.

    NoteIf logging is activated over a lengthy time period, this can have a negative effect on performance.

  6. Choose Continue.

 

regards,

Harish


Re: How to increase the duration of trace in SRT_UTIL

$
0
0

Hi Harish ,

 

Thanks for your reply,

as per your advise ,I have done the necessary changes in SRT_UTIL but still the payload trace is active only for 2 hours .I need to increase the trace to be active for minimum 4 hours . Please refer the below screen shot .

 

Note : I have activate the trace at 03.06.2016 11:28:40

 

SRT_UTIL_1.PNG

Thanks ,

Sakthikrishnan S .

ABAP Push Channel under huge load. Any best practices?

$
0
0

Hello,

I have a question regarding ABAP Push Channel, particularly about mixed scenario APC/AMC: http://scn.sap.com/community/abap/connectivity/blog/2014/04/14/abap-channels-part-3-collaboration-scenario-using-abap-messaging-and-abap-push-channels 

 

What if I am going to attach the functionality to some system event, which suddenly, starts happening very often?

 

For instance, I would like to inform technicians about the errors (e.g. IDOC postings), but then, incidentally, all IDOCs start to fail, thus thousand (or much more) messages must be send. BTW, IDOCs are normally posted in parallel, so this must be also considered.

 

So my questions are:

How to ensure that APC/AMC are working under huge load?

Any best practices or references?

What is huge load in this case?

 

The question is mainly to gurus – Olga and Masoud, but any hint would be appreciated.

Posting this as a separate question, as the topic is quite important to my mind.

 

Thanks, Dima

Modifications after Unicode conversion (ASP)

$
0
0

Hello experts,

Our system recently got converted to Unicode.

 

There are some traditional asp applications which communicate with the SAP R/3 system.

After the conversion, there are some errors while connecting.

 

I searched through and I have a clue that we need to include librfc32u.dll file with librfc32.dll file.

 

Can someone guide me step by step as to where do we need to include the files? And is there any other registry updates that I need to perform.

 

Any help in this regard would be appreciated,

 

Regards

Shubhendu

Re: Change inbound delivery using /SPE/IDOC_INPUT_DESADV1

$
0
0

Hi,

 

         I am having similar type of issue where customer exits will not work in this case.  We can update,insert or remove segment data using  BADI  "IDOC_DATA_MAPPER" .

 

 

Thanks,

Krunal.

Re: Modifications after Unicode conversion (ASP)

$
0
0

Hi Shubhendu,

 

> I searched through and I have a clue that we need to include librfc32u.dll file with librfc32.dll file.

This is not completely correct. librfc32u does not have to be used in addition to librfc32, but instead of it.

 

So what you need to do, is to replace the librfc32.dll with librfc32u.dll. However, this is not so simple: in the non-Unicode library all input/output data is handled as 1-byte char types, while in the "u-version" it is handled as 2-byte wchar_t type. Also the layout of the structures used by the ABAP function modules needs to be changed. So it means code changes in a few places and then re-compiling the application.

And now comes the really bad news: both, librfc32.dll as well as librfc32u.dll have reached their end-of-life 2 months ago... See Support for Classic RFC Library Ends March 2016

 

So instead of replacing librfc32.dll with librfc32u.dll, you would need to replace it with the "new" RFC library sapnwrfc.dll. This also needs a few code changes and re-compilation of the application.

 

So much as a short introduction to the topic... Now I want to point out a few things, which are not quite clear to me yet:

 

  1. First of all, a Unicode system is also capable of communicating in non-Unicode! So actually your old ASP applications should work fine just as before the conversion to Unicode! What errors do you get? Can you activate RFC trace to see what's going wrong?
  2. I can't believe that an ASP application is communicating directly with the librfc32.dll. Is it not rather the case, that the ASP application is using the old .NET Connector 2.0 (which is using librfc32.dll internally)? In that case it would perhaps be best to convert your ASP application to the new .NET Connector 3.0, if you really want to Unicode-enable it!

 

Best Regards, Ulrich

Re: ABAP Push Channel under huge load. Any best practices?

$
0
0

Hi Dima,

 

there exists a limitation for the number of AMC channels bound to WebSocket connections which can be adjusted using profile parameter, but for pushing messages to UI (WebSocket client) there exists (more or less) no limits for the number of messages transferred to the WebSocket client. Our tests, partly based on loadrunner, show that it is very hard to reach those (theoretical) limits. Just try to simulate the "heavy load" situation in your development system and if you would see any issues ,e.g. dropping of message just let us know.

 

We have a large number of unit tests which checks the consistency of ABAP Channel infrastructure. You as developer has also to test your software as good as possible, from different perspective, also regarding load test. Actually by increasing the number of AMC/APC producer you are able to generate more messages per seconds on the connection but you have to ensure that the consumer(s), e.g. the browser, is able to handler/consume those messages as well. My observation was, that if you send more than 100 messages per miliseconds to browsers you may observe issues regarding handling of those messages. Of course this depends on the JavaScript code and underlying library and garbage collector.

 

Cheers,

Masoud

Re: ABAP Push Channel under huge load. Any best practices?

$
0
0

Hello Masoud,

 

Real-life example: we have 6.000.000 stock updates in MSEG per day. We have 300 plants and we are thinking about having 300 channels (not easy to hndle it manually), as the data must be sent per plant. This results into 20.000 updates per plant per day or 14 updates per minute, in average. But, in fact, we so far have no clue how this is distributed in time. (We will definetely check it).

 

Therefore, it is very likely, we will have more (maybe much more) than 1 update per second.

 

Unfortunately our FE Fiori application is not capable to handle it so fast (e.g. 1 Hz at max).

 

So the question woudl be, how would you develop the back-end logic in this case?

 

The idea is to:

1. Delay processing of the messages;

2. Queue the messages;

3. Collect the messages;

4. Sent a collective message update;

 

Background job is not an option.

Do you have an idea, how all above can be reached? 

Can we, maybe, use qRFC with queue name as PLANT id?

 

Thanks and Regards,

Dima


Re: ABAP Push Channel under huge load. Any best practices?

$
0
0

Hi Dima,

the scenario would very likly create an issue at the FE side (Fiori), which has to be tested. In that case I would recommand to establish a "daemon", e.g. asynch. RFC session or APC stateful session in backend system (ABAP engine), which act as consumer of the messages and do the proper aggregation of the data to be sent to the WebSocket clients. Additionaly you should plan a batch job as watch dog to check the availbility/health of the "daemon" session.

 

Batch jobs, qRFC and bgRFCs as alternatives are - from my point of view - no options, as they do not provide any gurantee regarding the execution time of the tasks.

Cheers,

Masoud

Re: ABAP Push Channel under huge load. Any best practices?

$
0
0

Hello Masoud,

 

Thanks for the proposal.

We will investigate our case further and will try different options.

I will let you know.

 

Thanks and Regards,

Dima

Re: clearing invoice issue when using BAPI_ACC_DOCUMENT _POST

$
0
0

hi...

Using BAPI and function module, I want to post Incoming Payments (Transaction F-28) & clear respective open items in transaction FBL5N through program automatially.

 

i'm using BAPI_ACC_DOCUMENT_POST to post customer payment. &  it is posting succesfully.

But it is not clearing open customer Line Items when i see in FBL5N transaction.


I found my problem similar to yours. So, if possible please help me,


Thanks & regards...

Siddhesh

 

Re: clearing invoice issue when using BAPI_ACC_DOCUMENT _POST

$
0
0

Hi Siddesh,

 

BAPI_ACC_DOCUMENT_POST bapi alone will not clear the customer or vendor open line items, additionally you need to call FM: CLEAR_DOCUMENTS also.


Its worked for me.

 

Please find the coding snippet for clearing customer open line items.

 

 

*&---------------------------------------------------------------------*

*& Report  ZR_kunnr_CLEAR

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

 

 

REPORT zr_kunrr_clear NO STANDARD PAGE HEADING LINE-SIZE 160.

 

 

TABLES: bsid.

 

 

TYPES: BEGIN OF ty_budat,

         sign(1),

         option(2),

         low       TYPE  budat,

         high      TYPE  budat,

       END OF ty_budat.

 

 

TYPES: BEGIN OF ty_kunnr,

         sign(1),

         option(2),

         low       TYPE  kunnr,

         high      TYPE  kunnr,

       END OF ty_kunnr.

 

 

DATA:  l_kunnr        TYPE kunnr VALUE '474',

       t_budat        TYPE TABLE OF ty_budat,

       w_budat        TYPE ty_budat,

       t_kunnr        TYPE TABLE OF ty_kunnr,

       w_kunnr        TYPE  ty_kunnr,

       t_zdt_cust_det TYPE TABLE OF zdt_cust_det,

       w_zdt_cust_det TYPE  zdt_cust_det,

       t_errormsg     TYPE TABLE OF zst_errormsg1,

       w_errormsg     TYPE zst_errormsg1,

       t_bsid         TYPE TABLE OF bsid,

       w_bsid         TYPE  bsid,

       l_fiyrs        TYPE budat,

       l_fiyrt        TYPE allgstid,

       l_index        TYPE sy-index,

       l_belnr        TYPE belnr_d,

       l_message      TYPE char20,

       l_postingdate  TYPE budat,

       e_recordcount  TYPE int4.

 

 

SELECT-OPTIONS: so_kunnr FOR bsid-kunnr.

 

 

PARAMETERS    : p_fiyrt TYPE char4   OBLIGATORY DEFAULT '2010',

                p_bukrs TYPE bukrs   OBLIGATORY DEFAULT '1000'.

 

 

CLEAR: w_kunnr, w_budat, l_kunnr,l_fiyrs,l_fiyrt,l_postingdate.

 

 

CONCATENATE p_fiyrt '1231' INTO l_postingdate.

 

 

l_fiyrs = '19500101'.

CONCATENATE p_fiyrt '1231' INTO l_fiyrt .

 

 

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  EXPORTING

    input  = l_kunnr

  IMPORTING

    output = l_kunnr.

 

 

w_budat-sign   = 'I'.

w_budat-option = 'BT'.

w_budat-low    = l_fiyrs.

 

 

IF l_fiyrt IS NOT INITIAL.

  w_budat-high   = l_fiyrt.

ELSE.

  w_budat-high   = l_fiyrs.

ENDIF.

APPEND w_budat TO t_budat.

 

 

SELECT * FROM bsid INTO TABLE t_bsid WHERE bukrs = p_bukrs AND

                                           kunnr IN so_kunnr AND

                                           budat IN t_budat.

SORT t_bsid[] BY kunnr ASCENDING.

DELETE ADJACENT DUPLICATES FROM t_bsid COMPARING kunnr.

 

 

IF t_bsid[] IS NOT INITIAL.

 

 

  CALL FUNCTION 'ZFM_KUNNR_CLEAR'

    EXPORTING

      i_bukrs         = p_bukrs

      i_fiyrt         = p_fiyrt

    IMPORTING

      e_recordcount   = e_recordcount

    TABLES

      t_bsid          = t_bsid

      et_zdt_cust_det = t_zdt_cust_det

      et_errormsg     = t_errormsg.

ELSE.

  w_errormsg-sno = 1.

  w_errormsg-kunnr = ' '.

  w_errormsg-msg = 'No records found for search criteria'.

  APPEND w_errormsg TO t_errormsg.

ENDIF.

 

 

IF t_errormsg[] IS NOT INITIAL.

  WRITE:'Error Entries:'.

  SKIP.

ENDIF.

LOOP AT t_errormsg INTO w_errormsg.

  IF sy-tabix = 1.

    WRITE:/1 'S.NO', 15 'KUNNR', 22 'MESSAGE'.

    ULINE.

    SKIP.

  ENDIF.

  WRITE:/1 w_errormsg-sno, 15 w_errormsg-kunnr, 22 w_errormsg-msg.

ENDLOOP.

 

 

ULINE.

SKIP 3 .

WRITE:'Success Entries:'.

SKIP.

LOOP AT t_zdt_cust_det INTO w_zdt_cust_det.

  IF sy-tabix = 1.

    WRITE:/1 'Record Count:',e_recordcount.

    WRITE:/1 'S.NO',35 'BUKRS', 45 'KUNNR', 56 'BELNR', 71 'STATUS'.

    ULINE.

    SKIP.

  ENDIF.

  WRITE:/1 w_zdt_cust_det-z_sno, 35 w_zdt_cust_det-z_bukrs, 45 w_zdt_cust_det-z_kunnr, 55 w_zdt_cust_det-z_belnr, 70 w_zdt_cust_det-z_desc.

ENDLOOP.

 

 

*-------------------------------------------------------------------------------------------------------------------------------*

 

FUNCTION zfm_kunnr_clear.

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

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(I_BUKRS) TYPE  BUKRS OPTIONAL

*"     VALUE(I_FIYRT) TYPE  CHAR4 OPTIONAL

*"  EXPORTING

*"     VALUE(E_RESULT) TYPE  CHAR20

*"     VALUE(E_RECORDCOUNT) TYPE  INT4

*"  TABLES

*"      T_BSID STRUCTURE  BSID OPTIONAL

*"      ET_ZDT_CUST_DET STRUCTURE  ZDT_CUST_DET OPTIONAL

*"      ET_ERRORMSG STRUCTURE  ZST_ERRORMSG1 OPTIONAL

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

 

 

  DATA: w_bsid         TYPE bsid,

        t_lineitems    TYPE TABLE OF bapi3007_2,

        w_lineitems    TYPE bapi3007_2,

        w_return       TYPE bapireturn,

        l_kunnr        TYPE kunnr VALUE '474',

        t_zdt_cust_det TYPE TABLE OF zdt_cust_det,

        w_errormsg     TYPE  zst_errormsg1.

 

 

  DATA: w_doc_header        TYPE bapiache09,

        t_accountreceivable TYPE TABLE OF  bapiacar09,

        w_accountreceivable TYPE   bapiacar09,

        t_accountpayable    TYPE TABLE OF   bapiacap09,

        w_accountpayable    TYPE    bapiacap09,

        t_accounttax        TYPE TABLE OF   bapiactx09,

        w_accounttax        TYPE  bapiactx09,

        t_currencyamount    TYPE TABLE OF bapiaccr09,

        w_currencyamount    TYPE  bapiaccr09,

        t_extension2        TYPE TABLE OF   bapiparex,

        w_extension2        TYPE  bapiparex,

        t_extension1        TYPE TABLE OF   bapiacextc,

        w_extension1        TYPE    bapiacextc,

        t_accountgl         TYPE TABLE OF bapiacgl09,

        w_accountgl         TYPE  bapiacgl09,

        t_return            TYPE TABLE OF bapiret2,

        l_amount            TYPE char18,

        l_dmbtrp            TYPE bapidmbtr,

        l_result            TYPE bapidmbtr,

        l_dmbtrn            TYPE bapidmbtr,

        lv_type             TYPE bapiache09-obj_type,

        lv_key              TYPE bapiache09-obj_key,

        lv_sys              TYPE bapiache09-obj_sys,

        l_fiyrs             TYPE budat,

        l_fiyrt             TYPE allgstid,

        l_index             TYPE sy-index,

        l_belnr             TYPE belnr_d,

        l_datum             TYPE bapi3007-key_date,

        l_message           TYPE char20,

        l_postingdate       TYPE budat,

        l_count             TYPE i.

 

 

  CONCATENATE i_fiyrt '1231' INTO l_fiyrt.

  l_postingdate = l_fiyrt.

  REFRESH: et_zdt_cust_det[],et_errormsg[].

  CLEAR: l_kunnr,l_belnr.

  LOOP AT t_bsid INTO w_bsid.

 

 

    l_kunnr = w_bsid-kunnr.

 

 

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

        input  = l_kunnr

      IMPORTING

        output = l_kunnr.

 

 

    REFRESH t_lineitems[].

 

 

    CALL FUNCTION 'BAPI_AR_ACC_GETOPENITEMS'

      EXPORTING

        companycode = i_bukrs

        customer    = l_kunnr

        keydate     = l_fiyrt

      IMPORTING

        return      = w_return

      TABLES

        lineitems   = t_lineitems.

 

 

    DELETE t_lineitems WHERE clr_doc_no <> space.

 

 

*---Fill GL details-----*

    CLEAR: w_accountgl,w_doc_header,w_accountpayable,

    w_currencyamount, l_dmbtrp,l_dmbtrn,w_return,w_errormsg.

    REFRESH: t_accountgl[],t_accountpayable[],t_currencyamount[],

             t_extension1[],t_return[].

 

 

    w_accountgl-itemno_acc = '0000000001'.

    IF i_bukrs = '5000'.

      w_accountgl-gl_account = '0000111200'.

    ELSE.

      w_accountgl-gl_account = '0000113100'.

    ENDIF.

    w_accountgl-item_text  = 'Test'.

    w_accountgl-comp_code  = i_bukrs.

    w_accountgl-value_date = l_postingdate.

    w_accountgl-pstng_date = l_postingdate.

    w_accountgl-doc_type   = 'SA'.

    w_accountgl-fis_period = l_postingdate+4(2).

    w_accountgl-fisc_year  = l_fiyrt.

    APPEND  w_accountgl TO t_accountgl.

 

 

*---Fill Header details-----*

    w_doc_header-bus_act    = 'RFBU'.

    w_doc_header-obj_type   = 'BKPFF'.

    w_doc_header-obj_key    = '$'.

    w_doc_header-obj_sys    = 'T90CLNT090'.

    w_doc_header-username   = sy-uname.

    w_doc_header-header_txt = 'Customer Openitem clearance'.

    w_doc_header-comp_code  = i_bukrs.

    w_doc_header-doc_date   = l_postingdate.

    w_doc_header-pstng_date = l_postingdate.

    w_doc_header-doc_type   = 'SA'.

 

 

*---Fill Vendor details---------*

    w_accountreceivable-itemno_acc  = '0000000002'.

    w_accountreceivable-customer   = l_kunnr.

    w_accountreceivable-comp_code   = i_bukrs.

    APPEND w_accountpayable TO t_accountpayable.

 

 

*------Segregating Positive and Negative Amounts---------------------*

    SORT t_lineitems[] ASCENDING BY amt_doccur.

    CLEAR: w_lineitems.

    LOOP AT t_lineitems INTO w_lineitems.

 

 

      IF w_lineitems-db_cr_ind = 'S'.

        l_dmbtrp = w_lineitems-lc_amount + l_dmbtrp.

      ELSE.

        l_dmbtrn = w_lineitems-lc_amount + l_dmbtrn.

      ENDIF.

 

 

    ENDLOOP.

    l_dmbtrn = -1 * l_dmbtrn.

    l_result = l_dmbtrp + l_dmbtrn.

*------Segregating Positive and Negative Amounts--------------------*

 

 

*------Fill Currency Amount and posting key if amount is Positive---*

    IF l_dmbtrp IS NOT INITIAL.

      w_currencyamount-itemno_acc   = '0000000001'.

      w_currencyamount-currency_iso = 'EUR'.

      w_currencyamount-amt_doccur   =  l_dmbtrp.

      APPEND w_currencyamount TO t_currencyamount.

 

 

      l_dmbtrp = -1 * l_dmbtrp.

      w_currencyamount-itemno_acc   = '0000000002'.

      w_currencyamount-currency_iso = 'EUR'.

      w_currencyamount-amt_doccur   = l_dmbtrp.

      APPEND w_currencyamount TO t_currencyamount.

 

 

      w_extension1-field1 = '000000000140'.

      APPEND w_extension1 TO t_extension1.

 

 

      w_extension1-field1 = '000000000237'.

      APPEND w_extension1 TO t_extension1.

    ENDIF.

*------Fill Currency Amount and posting key if amount is Positive----*

 

 

*------Fill Currency Amount and posting key if amount is negative------*

    IF l_dmbtrn IS NOT INITIAL.

 

 

      IF l_dmbtrp IS INITIAL.

        w_currencyamount-itemno_acc = '0000000001'.

        w_extension1-field1         = '000000000150'.

      ELSE.

        w_currencyamount-itemno_acc = '0000000003'.

        w_extension1-field1         = '000000000350'.

      ENDIF.

      w_currencyamount-currency_iso = 'EUR'.

      w_currencyamount-amt_doccur = l_dmbtrn.

      APPEND w_currencyamount TO t_currencyamount.

      APPEND w_extension1 TO t_extension1.

 

 

      l_dmbtrn = -1 * l_dmbtrn.

      IF l_dmbtrp IS INITIAL.

        w_currencyamount-itemno_acc = '0000000002'.

        w_extension1-field1         = '000000000227'. "posting key

      ELSE.

        w_currencyamount-itemno_acc = '0000000004'.

        w_extension1-field1         = '000000000427'. "posting key

      ENDIF.

      w_currencyamount-currency_iso = 'EUR'.

      w_currencyamount-amt_doccur = l_dmbtrn.

      APPEND w_currencyamount TO t_currencyamount.

      APPEND w_extension1 TO t_extension1.

 

 

    ENDIF.

*------Fill Currency Amount and posting key if amount is negative----*

 

 

    CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'

      EXPORTING

        documentheader    = w_doc_header

      TABLES

        accountgl         = t_accountgl

        accountreceivable = t_accountreceivable

        currencyamount    = t_currencyamount

        extension1        = t_extension1

        return            = t_return.

 

 

    REFRESH: t_return[].

 

 

    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

      EXPORTING

        documentheader    = w_doc_header

      IMPORTING

        obj_type          = lv_type

        obj_key           = lv_key

        obj_sys           = lv_sys

      TABLES

        accountgl         = t_accountgl

        accountreceivable = t_accountreceivable

        currencyamount    = t_currencyamount

        extension1        = t_extension1

        return            = t_return.

 

 

    READ TABLE t_return INTO w_return WITH KEY type = 'E'.

 

 

    IF sy-subrc <> 0.

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

*------Clear Customer Open lineitems--------*

      l_belnr = lv_key+0(10).

      CLEAR: l_message.

      WAIT UP TO 1 SECONDS.

      CALL FUNCTION 'ZFM_CLEAR_DOCUMENTS_KUNNR'

        EXPORTING

          i_kunnr         = l_kunnr

          i_belnr         = l_belnr

          i_keydate       = l_postingdate

          i_fisyr         = i_fiyrt

          i_bukrs         = i_bukrs

        IMPORTING

          e_message       = l_message

          e_recordcount   = e_recordcount

        TABLES

          et_zdt_vend_det = t_zdt_cust_det

          it_lineitems    = t_lineitems.

*------Clear Customer Open lineitems--------*

    ELSE.

      LOOP AT t_return INTO w_return.

        l_count  = l_count + 1.

        w_errormsg-sno   = l_count.

        w_errormsg-kunnr = l_kunnr.

        w_errormsg-msg   = w_return-message.

        APPEND w_errormsg TO et_errormsg.

        CLEAR:w_errormsg,w_return,l_belnr,l_kunnr.

      ENDLOOP.

    ENDIF.

    APPEND LINES OF t_zdt_cust_det[] TO et_zdt_cust_det[].

    CLEAR: w_lineitems.

  ENDLOOP.

 

 

ENDFUNCTION.

 

*-------------------------------------------------------------------------------------------------------------------------------*

 

 

 

 

FUNCTION zfm_clear_documents_kunnr.

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

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(I_KUNNR) TYPE  LIFNR

*"     VALUE(I_BELNR) TYPE  BELNR_D

*"     VALUE(I_KEYDATE) TYPE  BAPI3007-KEY_DATE DEFAULT '20141231'

*"     VALUE(I_FISYR) TYPE  CHAR4

*"     VALUE(I_BUKRS) TYPE  BUKRS

*"  EXPORTING

*"     VALUE(E_MESSAGE) TYPE  CHAR20

*"     VALUE(E_RECORDCOUNT) TYPE  INT4

*"  TABLES

*"      ET_ZDT_CUST_DET STRUCTURE  ZDT_VEND_DET OPTIONAL

*"      IT_LINEITEMS STRUCTURE  BAPI3007_2 OPTIONAL

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

 

 

 

 

  TYPES: BEGIN OF ty_belnr,

           sign(1),

           option(2),

           low       TYPE  augbl,

           high      TYPE  augbl,

         END OF ty_belnr.

 

 

  DATA: t_lineitems    TYPE TABLE OF bapi3007_2,

        w_lineitems    TYPE bapi3007_2,

        t_belnr        TYPE TABLE OF ty_belnr,

        w_belnr        TYPE  ty_belnr,

        t_bsad         TYPE TABLE OF bsad,

        w_bsid         TYPE bsid,

        w_bsad         TYPE bsad,

        t_zdt_cust_det TYPE TABLE OF zdt_cust_det,

        w_zdt_cust_det TYPE  zdt_cust_det,

        w_return       TYPE bapireturn,

        l_kunnr        TYPE kunnr VALUE '474',

        t_ausz1        TYPE TABLE OF ausz1,

        w_ausz1        TYPE ausz1,

        t_ausz2        TYPE TABLE OF ausz2,

        w_ausz2        TYPE ausz2,

 

 

        l_belnr        TYPE belnr_d,

        l_count        TYPE int4,

        l_fisyr        TYPE char4,

        l_sno          TYPE int4,

        l_postingdate  TYPE budat,

        t_bsik         TYPE TABLE OF bsik.

 

 

  CLEAR: w_ausz1,w_ausz2,w_lineitems,l_count,l_kunnr,

  l_postingdate,w_lineitems,l_belnr,l_fisyr,

  e_recordcount.

  REFRESH: t_lineitems[],t_ausz1,t_ausz2.

 

 

  l_kunnr       = i_kunnr.

 

 

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

      input  = l_kunnr

    IMPORTING

      output = l_kunnr.

 

 

  l_belnr       = i_belnr.

  l_fisyr       = i_fisyr.

  l_postingdate = i_keydate.

 

 

  CALL FUNCTION 'BAPI_AP_ACC_GETOPENITEMS'

    EXPORTING

      companycode = i_bukrs

      customer    = l_kunnr

      keydate     = l_postingdate

    IMPORTING

      return      = w_return

    TABLES

      lineitems   = t_lineitems.

  SORT t_lineitems BY doc_no ASCENDING.

  DELETE t_lineitems WHERE clr_doc_no <> space.

*  delete ADJACENT DUPLICATES FROM t_lineitems COMPARING doc_no.

 

 

  SELECT SINGLE * FROM bsid INTO w_bsid WHERE bukrs = i_bukrs AND

                                              kunnr = l_kunnr AND

                                              belnr = l_belnr.

  IF sy-subrc = 0.

    SORT t_lineitems[] BY pstng_date ASCENDING item_num ASCENDING.

    DESCRIBE TABLE t_lineitems LINES l_count.

    LOOP AT t_lineitems INTO w_lineitems.

      e_recordcount  = e_recordcount + 1.

      w_ausz1-belnr = w_lineitems-doc_no.

      w_ausz1-bukrs = w_lineitems-comp_code.

      w_ausz1-gjahr = w_lineitems-fisc_year.

      w_ausz1-buzei = w_lineitems-item_num.

      APPEND w_ausz1 TO t_ausz1.

 

 

      w_ausz2-bukrs = w_bsid-bukrs.

      w_ausz2-aktio = 'A'.

      w_ausz2-augbl = w_bsid-belnr.

      w_ausz2-augdt = l_postingdate.

      w_ausz2-auggj = w_bsid-gjahr.

      APPEND w_ausz2 TO t_ausz2.

 

 

      CALL FUNCTION 'CLEAR_DOCUMENTS' " IN UPDATE TASK

        TABLES

          t_ausz1 = t_ausz1

          t_ausz2 = t_ausz2.

 

 

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

 

 

      w_belnr-sign    = 'I'.

      w_belnr-option  = 'EQ'.

      w_belnr-low     = w_lineitems-doc_no.

      APPEND w_belnr TO t_belnr.

      CLEAR: w_lineitems,w_belnr.

      REFRESH: t_ausz2[],t_ausz1[].

    ENDLOOP.

 

 

    SELECT * FROM bsad INTO TABLE t_bsad WHERE bukrs = i_bukrs AND

                                               kunnr = l_kunnr AND

                                               belnr IN t_belnr.

    IF t_bsad[] IS NOT INITIAL.

      CLEAR: w_lineitems ,w_bsad,w_zdt_cust_det,l_sno.

      LOOP AT t_lineitems INTO w_lineitems.

 

 

        READ TABLE t_bsad INTO w_bsad WITH KEY bukrs = w_lineitems-comp_code

                                               kunnr = w_lineitems-customer

                                               belnr = w_lineitems-doc_no.

        CALL FUNCTION 'GUID_CREATE'

          IMPORTING

            ev_guid_16 = w_zdt_cust_det-z_sno.

 

 

        IF sy-subrc = 0.

          w_zdt_cust_det-z_bukrs       = w_bsad-bukrs.

          w_zdt_cust_det-z_kunnr       = w_bsad-kunnr.

          w_zdt_cust_det-z_belnr       = w_bsad-belnr.

          w_zdt_cust_det-z_status      = 'X'.

          w_zdt_cust_det-z_clearingdoc = l_belnr.

          w_zdt_cust_det-z_desc        = 'Cleared'.

          APPEND w_zdt_cust_det TO t_zdt_cust_det.

 

 

        ELSE.

          w_zdt_cust_det-z_bukrs       = w_lineitems-comp_code.

          w_zdt_cust_det-z_kunnr       = w_lineitems-customer.

          w_zdt_cust_det-z_belnr       = w_lineitems-doc_no.

          w_zdt_cust_det-z_status      = ' '.

          w_zdt_cust_det-z_clearingdoc = ' '.

          w_zdt_cust_det-z_desc        = 'Not cleared'.

          APPEND w_zdt_cust_det TO t_zdt_cust_det.

        ENDIF.

        CLEAR: w_lineitems ,w_bsad,w_zdt_cust_det.

 

 

      ENDLOOP.

 

 

*-----Update Log Table------------*

      INSERT zdt_cust_det FROM TABLE t_zdt_cust_det.

      IF sy-subrc = 0.

        e_message = 'update sucess'.

      ELSE.

        e_message = 'update fail'.

      ENDIF.

      et_zdt_cust_det[] = t_zdt_cust_det[].

      REFRESH:t_zdt_cust_det[].

 

 

    ENDIF.

  ENDIF.

ENDFUNCTION.

Re: Create Business Partners with LSMW and IDOC

Viewing all 3125 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>