cancel
Showing results for 
Search instead for 
Did you mean: 

assign a sentence in header vendor text in PO

Former Member
0 Kudos

Hello all,

in case of limit item SC, i want to add automatically a sentence in the header vendor text in PO if the expected amount is less than the limit amount.

I created a new method in badi 'BBP_PO_CHANGE' and i used the parameter ct_longtext as below.

DELETE ct_longtext WHERE  tdid = 'HTXT'. " Clear vendor text

         APPEND INITIAL LINE TO ct_longtext ASSIGNING <fs_text>.

         IF <fs_text> IS ASSIGNED.

           <fs_text>-guid = is_header-guid.

           <fs_text>-tdid = 'HTXT'.

           <fs_text>-tdspras = lv_lang.

           <fs_text>-tdline = text_itab.

*          unASSIGN <fs_text>.

         ENDIF.





Here is my problem: the sentence is displayed only when i edit the PO. But i want it to be displayed automatically once the PO is created.

Couild you help me .

thanks,

Meriem.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hello all,

oss  1612828 may help.

Answers (3)

Answers (3)

robin_janke
Contributor
0 Kudos

The doc change badi is also called when creating a PO (introduce a conditional endless loop in your code and view in sm50 to check).

Your code works as wanted, seeing that an edit does work.

Please try to sort your ct_longtext table after you add your text on TDID, and see if that matters.

Regards,

Robin

Former Member
0 Kudos

hello Robin,

here is my coding:

CALL METHOD me->set_header_vendor_text_limi

       EXPORTING

         iv_mode = iv_mode

         is_header   = is_header

       IMPORTING

         ct_longtext = ct_longtext.



METHOD set_header_vendor_text_limi.

   DATA : e_item TYPE TABLE OF bbp_pds_po_item_d,

         wa_item TYPE bbp_pds_po_item_d,

         e_limit TYPE TABLE OF bbp_pds_limit,

         e_partner TYPE TABLE OF bbp_pds_partner,

         l_tlines          TYPE TABLE OF tline,

         wa_line TYPE tline,

         wa_partner        TYPE  bbp_pds_partner,

         l_add TYPE string,

         lv_lang TYPE ad_langucr,

         l_language TYPE string ,

          ls_but000 TYPE bus000,

          text_itab         TYPE string,

          t_text_itab       TYPE string,

   wa_limit TYPE bbp_pds_limit.

   FIELD-SYMBOLS<fs_text> LIKE LINE OF ct_longtext.

   CALL FUNCTION 'BBP_PD_PO_GETDETAIL'

    EXPORTING

      i_guid                           = is_header-guid

*   I_OBJECT_ID                      =

*   I_ATTACH_WITH_DOC                = ' '

    i_with_itemdata                  = 'X'

    i_without_header_totals          = 'X'

* IMPORTING

*   E_HEADER                         =

*   ET_ATTACH                        =

    TABLES

      e_item                           = e_item

      e_partner                     = e_partner

*   E_LONGTEXT                       =

*   E_SDLN                           =

      e_limit                          = e_limit.

   READ TABLE e_partner INTO wa_partner WITH KEY     partner_fct '00000019'.

   IF sy-subrc EQ 0.

     CLEAR ls_but000.

     CLEAR l_language.

     MOVE wa_partner-addr_no TO l_add.

     SELECT SINGLE langu_crea FROM adrc INTO lv_lang WHERE addrnumber = l_add.

     IF lv_lang IS INITIAL.

       lv_lang = 'E'.

     ENDIF.

*    CALL FUNCTION 'BUP_PARTNER_GET'

*      EXPORTING

*        i_partner = l_partner

*      IMPORTING

*        e_but000  = ls_but000.

   ENDIF.

   READ TABLE e_item INTO wa_item WITH KEY del_ind = space.

   IF sy-subrc = 0.

* limit item SC

     IF wa_item-itm_type = 'LIMI'.

       READ TABLE e_limit INTO wa_limit WITH KEY lim_type = 'G'  .

       IF wa_limit-exp_value < wa_limit-limit.

         CALL FUNCTION 'READ_TEXT'

           EXPORTING

             client   = sy-mandt

             id       = 'ST'

             language = lv_lang

             name     = 'Z_HEADER_VENDOR_TEXT_PO'

             object   = 'TEXT'

           TABLES

             lines    = l_tlines.

         LOOP AT l_tlines INTO wa_line.

           t_text_itab = wa_line-tdline.

           CONCATENATE text_itab t_text_itab INTO text_itab SEPARATED BY space.

         ENDLOOP.

*        READ TABLE l_tlines  INTO wa_line INDEX 1.

*        IF sy-subrc <> 0.

         DELETE ct_longtext WHERE  tdid = 'HTXT'. " Clear vendor text

         APPEND INITIAL LINE TO ct_longtext ASSIGNING <fs_text>.

         IF <fs_text> IS ASSIGNED.

           <fs_text>-guid = is_header-guid.

           <fs_text>-tdid = 'HTXT'.

           <fs_text>-tdspras = lv_lang.

           <fs_text>-tdline = text_itab.

*          unASSIGN <fs_text>.

         ENDIF.

*        ENDIF.

       ENDIF.

     ENDIF.

   ENDIF.

ENDMETHOD.





could you help me more.


thanks

Former Member
0 Kudos

Hello all,

can any body help me with this.

i think using read_text and save_text is not a good idea.

i want to use the parameter ct-longtext.

thanks,

Meriem.

Former Member
0 Kudos

Hi again,

Believe me I do not completely understand your problem.

Who are creating the PO?

BAdI Change is intended to be executed after user input but before saving (i.e. you change some field value and press enter, ...).

What I do not get is how a user can create a PO without modifying it. I understand the process as: user selects create PO from Portal/NWBC, fills in all data and then press save or submit. So, as soon as user fills in a value and some action is performed (check, enter, save, submit, changing value in some dropdowns fields, etc, taking into account that not all fields are able to "roundtrip" ==> check Generic Field Display on User Interface in spro), BAdI change should be executed and your custom LT should be modified. I can tell you that BAdI change is executed when you create a PO (not only when you are editing an existing one). That's for sure... Once your WD context is properly filled in (including your new LT), such context values are stored into DB via Mappers&CLL classes and PD/PDO layers.

"But once the PO is created, the system skips the badi and the vendor text still empty." ==>BAdI should be executed before saving and custom changes are also intended to be saved...

Are you creating PO from custom program, from SOCO, approved SC/Response or something similar? Cause using a normal user interaction PO creation, I think BAdI change should do exactly what you want :S. I guess that you are involuntary clearing LT in some BAdI call or so.

Just another hint, I remember some problems related to UI not getting informed about some changes been performed by coding, so sometimes "set changed by client" property has to be explicitly coded in some way, but I think it is more related to WD and this is something pretty obvious in this BAdI. Please try to also modify another field at header or item level (informing the corresponding output wa/itab) and cross fingers...

I hope you get a solution

Good luck and regards

Vicente

Former Member
0 Kudos

Hello again,

i will explain with more details this time.

the target is to fill per default the header vendor text in PO.

For that, i created a new method in badi change using ct_longtext parameter.

to test my coding, i created a SC, approved it. Once the PO was created, i checked the vedor field but it still empty.

but, when i edit the PO and reorder it, the header vendor text is filled.

i am wondering if i used the wrong parameter.

i follwed the badi through debugging from the SC creation till the approval of PO.

the system executed the new method, filled ct_parameter but nothing happens.

i wish i was clear this time.

thanks,

Meroem.

Former Member
0 Kudos

Hiho,

Now I understand. What I did not know is that you are creating PO automatically from approved SC.

Ok, BAdI change is not executed in such scenario. As you already realized, it is executed after user inputs (after edition)...

So, what you can do is i) create the LT in SC badi change and use inheritance to PO or ii) make an implicit enhancement in the FM that create the PO from the approved SC (BBP_PD_SC_TRANSFER_MULTI in my SRM implementation).

Also check BBP_LONGTEXT_BADI in case you have problems copying LTs from SC to PO.

I hope this helps.

I am sure you will solve it

Vicente

Former Member
0 Kudos

Hi Meriem,

Have you tried in BAdI save instead of BAdI change?

Regards

Vicente

Former Member
0 Kudos

Hi Vicente, 

parameter ct_longtext does not exit in this Badi.

Regards,

Meriem.

Former Member
0 Kudos

You are right,

I do not think it is a good idea, but you can try to call FM READ_TEXT in badi save and see whether long text is already stored when badi is called (I think badi is executed before long texts are saved in DB :S):

ID                              HTXT

LANGUAGE                        EN

NAME                            E6DB2655249B1333E10000000A109296

OBJECT                          BBP_PD

If you can get long text via READ_TEXT, you could get data, modify text and make a SAVE_TEXT.

On the other hand, I do not completely understand your concern. PO has to be edited before creation, so badi change should be executed always before creation. I should be miss understanding your requirement. Probably the PO is automatically created from approved SC? If so, you could try to enhance the transfer FM.

Regards

Vicente

Former Member
0 Kudos

i will try your suggestion.

What i wanted to say is the following:

i implemented my code in change badi. But once the PO is created, the system skips the badi and the vendor text still empty.

the changes happens only when i edit the po