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: 

Proposing destination storage bin using FM L_TO_PREPARE_ITEM_INT

Former Member
1,791

Hi friends,

I am trying to use FM L_TO_PREPARE_ITEM_INT to get the proposed destination storage bin.  I am trying to determine the correct/required parameter values for the FM.

I did a lot of research on this issue and found little, the most promising was a post that I've used as a basis for my work so far.  My code is below.

Using transaction LM00, choose stock put away/put away by GRN/enter material document number.  Then select pick.  At this point the destination storage bin to locate the product should be suggested.

My code is in include program LZRFBF09, module/form lzrfb_pbo_0903_init the following code was added.  The code was placed here to get the destination storage bin value  before the display of screen 903.

This should be similar behavior as LT04/System guided/Putaway in foreground.  The idea is to have the proposed destination storage bin displayed on the screen, which can be accepted or changed by the user, before proceeding with the putaway.

When I run this now and press F5/Pick, I am receiving the error “System cannot find source storage bin”.  My thoughts are that the parameters for the function module are incorrect or something is missing, but I cannot work out what it could be.

* I would prefer to use this FM to accomplish this task, rather than trying a different way.  Of course if you know for a fact that that this method won't work, please feel free to share an alternate way to do this.

Thank you for your input.

My code:

* FM to get proposed destinaton storage bin

* Fill structures

  DATA: gs_ltbk TYPE zrfb_ltbk_t,

        gs_ltbp TYPE zrfb_ltbp_t.

  READ TABLE gt_ltbk INTO gs_ltbk INDEX g_count.

  READ TABLE gt_ltbp INTO gs_ltbp INDEX g_count.

*  SELECT SINGLE  * FROM lein INTO wa_lein       " << BOTH OF THESE SELECTS RETURN SY-SUBRC = 4 (wrong test data, or is this not needed?)

*    WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum " << user parameter retrieved earlier

*    AND   letyp = gs_ltbk-vltyp.

*  IF sy-subrc = 0.

    SELECT SINGLE * FROM lqua INTO lt_lqua     " << BOTH OF THESE SELECTS RETURN SY-SUBRC = 4

      WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum " << user parameter retrieved earlier

*      WHERE lgnum = wa_lein-lgnum

      AND   lgtyp = gs_ltbk-vltyp   " wa_lein-lgtyp

      AND   lgpla = gs_ltbk-vlpla   " wa_lein-lgpla

      .

*      AND   lenum = wa_lein-lenum.

*  ENDIF.

* ltak

*  MOVE-CORRESPONDING gs_ltbk TO le_ltak.

*  le_ltak-lgnum = xr_tran_rawmso-r_uparam-s_lgnum.

  le_ltak-lgnum = lt_lqua-lgnum.

  le_ltak-bwlvs = '999'.

*  le_ltak-bwlvs = gs_ltbk-bwlvs.

* ltap

*  MOVE-CORRESPONDING gs_ltbp TO le_ltap.

*  le_ltap-fhuta = '1'.  " TESTING

  MOVE-CORRESPONDING lt_lqua TO le_ltap.

*  le_ltap-vsolm = gs_ltbp-qty.

*  le_ltap-vistm = gs_ltbp-qty.

*  le_ltap-nsolm = gs_ltbp-qty.

*  le_ltap-nistm = gs_ltbp-qty.

* mlvs

  MOVE: 'MLVS' TO lt_mtcom-kenng,

        'MMSTA' TO lt_mtcom-t141_feld,

        lt_lqua-matnr to lt_mtcom-matnr, "gs_ltbp-matnr TO lt_mtcom-matnr,

        gs_ltbp-werks TO lt_mtcom-werks,

        xr_tran_rawmso-r_uparam-s_lgnum TO lt_mtcom-lgnum,

        sy-langu TO lt_mtcom-spras.

  CALL FUNCTION 'MATERIAL_READ'

    EXPORTING

      schluessel         = lt_mtcom

    IMPORTING

      matdaten           = le_mlvs

      return             = lt_mtcor

    EXCEPTIONS

      material_not_found = 1.

* mgef

  SELECT SINGLE regkz FROM t300 INTO lv_t300_regkz

                           WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum.

  IF sy-subrc = 0.

    SELECT SINGLE * INTO le_mgef  " SELECT RETURNS SY-SUBRC = 4

      FROM mgef

      WHERE stoff = le_mlvs-stoff

      AND regkz = lv_t300_regkz.

  ENDIF.

* rl03a

*    le_r103a-multa = .

  le_rl03a-anfme = gr_tran_rawmso-r_scr_0902-s_qty. " gs_ltbp-to_qty.

  le_rl03a-anfml = gr_tran_rawmso-r_scr_0902-s_qty. " gs_ltbp-to_qty.

*    le_rl03a-squit =

  le_rl03a-vorga = 'IV'. " 'Q'.

*    le_rl03a-kzuap =

  le_rl03a-proto = ''.

* t333

  SELECT SINGLE * INTO le_t333

    FROM t333

    WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum " << user parameter retrieved earlier

  AND bwlvs = '999'. "gs_ltbk-bwlvs.

  IF le_t333-vltyp IS INITIAL.

*    MOVE gs_ltbk-vltyp TO le_t333-vltyp.

  ENDIF.

* t334t

  le_t334t-mandt = sy-mandt.

  le_t334t-lgnum = xr_tran_rawmso-r_uparam-s_lgnum.

  le_t334t-kzear = 'E'.

  le_t334t-lgtkz = gr_tran_rawmso-r_scr_0902-s_styp. " ''.

  le_t334t-bestq = gs_ltbp-bestq.

  le_t334t-sobkz = gs_ltbp-sobkz.

* t340d

  SELECT SINGLE * INTO le_t340d

    FROM t340d

    WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum.

* make function call

  CALL FUNCTION 'L_TO_PREPARE_ITEM_INT'

    EXPORTING

      i_ltak               = le_ltak

      i_ltap               = le_ltap

      i_mlvs               = le_mlvs

      i_mgef               = le_mgef

      i_rl03a              = le_rl03a

      i_t333               = le_t333

      i_t334t              = le_t334t

      i_t340d              = le_t340d

   IMPORTING

     e_ltap               = li_ltap

*     e_reduz              = li_reduz

    TABLES

      t_lprot              = lt_lprot

      t_lmess              = lt_lmess

   EXCEPTIONS

     call_forbidden       = 1

     OTHERS               = 2

            .

1 REPLY 1

Former Member
351

**UPDATED**

I have since made some modifications to my code.

The select statement from lein has been commented, and the select from lqua is successful.

DATA: gs_ltbk TYPE zrfb_ltbk_t,

         gs_ltbp TYPE zrfb_ltbp_t.

   READ TABLE gt_ltbk INTO gs_ltbk INDEX g_count.

   READ TABLE gt_ltbp INTO gs_ltbp INDEX g_count.

*  SELECT SINGLE  * FROM lein INTO wa_lein      " << BOTH OF THESE SELECTS RETURN SY-SUBRC = 4

*    WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum

*    AND   letyp = gs_ltbk-vltyp.

*  IF sy-subrc = 0.

     SELECT SINGLE * FROM lqua INTO lt_lqua     " << BOTH OF THESE SELECTS RETURN SY-SUBRC = 4

       WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum

*      WHERE lgnum = wa_lein-lgnum

       AND   lgtyp = gs_ltbk-vltyp   " wa_lein-lgtyp

       AND   lgpla = gs_ltbk-vlpla   " wa_lein-lgpla

       .

However, the select from mgef fails:

IF sy-subrc = 0.

     SELECT SINGLE * INTO le_mgef  " SELECT RETURNS SY-SUBRC = 4

       FROM mgef

       WHERE stoff = le_mlvs-stoff

       AND regkz = lv_t300_regkz.

   ENDIF.


************************************************************************************

************************************************************************************

THE MODIFIED CODE:

DATA: gs_ltbk TYPE zrfb_ltbk_t,

         gs_ltbp TYPE zrfb_ltbp_t.

   READ TABLE gt_ltbk INTO gs_ltbk INDEX g_count.

   READ TABLE gt_ltbp INTO gs_ltbp INDEX g_count.

*  SELECT SINGLE  * FROM lein INTO wa_lein      " << BOTH OF THESE SELECTS RETURN SY-SUBRC = 4

*    WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum

*    AND   letyp = gs_ltbk-vltyp.

*  IF sy-subrc = 0.

     SELECT SINGLE * FROM lqua INTO lt_lqua     " << BOTH OF THESE SELECTS RETURN SY-SUBRC = 4

       WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum

*      WHERE lgnum = wa_lein-lgnum

       AND   lgtyp = gs_ltbk-vltyp   " wa_lein-lgtyp

       AND   lgpla = gs_ltbk-vlpla   " wa_lein-lgpla

       .

*      AND   lenum = wa_lein-lenum.

*  ENDIF.

* ltak

*  MOVE-CORRESPONDING gs_ltbk TO le_ltak.

*  le_ltak-lgnum = xr_tran_rawmso-r_uparam-s_lgnum.

   le_ltak-lgnum = lt_lqua-lgnum.

   le_ltak-bwlvs = '999'.

*  le_ltak-bwlvs = gs_ltbk-bwlvs.

* ltap

*  MOVE-CORRESPONDING gs_ltbp TO le_ltap.

*  le_ltap-fhuta = '1'.  " TESTING

   MOVE-CORRESPONDING lt_lqua TO le_ltap.

*  le_ltap-vsolm = gs_ltbp-qty.

*  le_ltap-vistm = gs_ltbp-qty.

*  le_ltap-nsolm = gs_ltbp-qty.

*  le_ltap-nistm = gs_ltbp-qty.

* mlvs

   MOVE: 'MLVS' TO lt_mtcom-kenng,

         'MMSTA' TO lt_mtcom-t141_feld,

         lt_lqua-matnr to lt_mtcom-matnr, "gs_ltbp-matnr TO lt_mtcom-matnr,

         gs_ltbp-werks TO lt_mtcom-werks,

         xr_tran_rawmso-r_uparam-s_lgnum TO lt_mtcom-lgnum,

         sy-langu TO lt_mtcom-spras.

   CALL FUNCTION 'MATERIAL_READ'

     EXPORTING

       schluessel         = lt_mtcom

     IMPORTING

       matdaten           = le_mlvs

       return             = lt_mtcor

     EXCEPTIONS

       material_not_found = 1.

* mgef

   SELECT SINGLE regkz FROM t300 INTO lv_t300_regkz

                            WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum.

   IF sy-subrc = 0.

     SELECT SINGLE * INTO le_mgef  " SELECT RETURNS SY-SUBRC = 4

       FROM mgef

       WHERE stoff = le_mlvs-stoff

       AND regkz = lv_t300_regkz.

   ENDIF.

* rl03a

*    le_r103a-multa = .

   le_rl03a-anfme = gr_tran_rawmso-r_scr_0902-s_qty. " gs_ltbp-to_qty.

   le_rl03a-anfml = gr_tran_rawmso-r_scr_0902-s_qty. " gs_ltbp-to_qty.

*    le_rl03a-squit =

   le_rl03a-vorga = 'IV'. " 'Q'.

*    le_rl03a-kzuap =

   le_rl03a-proto = ''.

* t333

   SELECT SINGLE * INTO le_t333

     FROM t333

     WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum

     AND bwlvs = '999'."gs_ltbk-bwlvs.                              "999.

   IF le_t333-vltyp IS INITIAL.

*    MOVE gs_ltbk-vltyp TO le_t333-vltyp.

   ENDIF.

* t334t

   le_t334t-mandt = sy-mandt.

   le_t334t-lgnum = xr_tran_rawmso-r_uparam-s_lgnum.

   le_t334t-kzear = 'E'.

   le_t334t-lgtkz = gr_tran_rawmso-r_scr_0902-s_styp. " ''.

   le_t334t-bestq = gs_ltbp-bestq.

   le_t334t-sobkz = gs_ltbp-sobkz.

* t340d

   SELECT SINGLE * INTO le_t340d

     FROM t340d

     WHERE lgnum = xr_tran_rawmso-r_uparam-s_lgnum.

* make function call

   CALL FUNCTION 'L_TO_PREPARE_ITEM_INT'

     EXPORTING

       i_ltak               = le_ltak

       i_ltap               = le_ltap

       i_mlvs               = le_mlvs

       i_mgef               = le_mgef

       i_rl03a              = le_rl03a

       i_t333               = le_t333

       i_t334t              = le_t334t

       i_t340d              = le_t340d

    IMPORTING

      e_ltap               = li_ltap

*     e_reduz              = li_reduz

     TABLES

       t_lprot              = lt_lprot

       t_lmess              = lt_lmess

    EXCEPTIONS

      call_forbidden       = 1

      OTHERS               = 2

             .

   IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.


****************************************************************************************************

****************************************************************************************************

The message now is:

Storage type 005 does not allow negative stock figures