Skip to Content
0
Jun 18, 2015 at 03:29 PM

LSWM _BEGIN_OF_RECORD_ Allowed Code

27 Views

hi,

i'm trying to make a LSMW to create BoMs.

i can't use the standard batch input method since there are custom fields for the item positions and i get a dump for conversion error.

therefore i went for the recording method.

i created the header first and then i used recordings in order to add the positions, that would be the idea at least.

i had to do several recording for the item positions because different position types generate different dynpro sequences and adding the first item position also generates a different dynpro sequence compared to subsequent item positions.

basically i have several recordings and i'm trying to add some code in the _BEGIN_OF_RECORD_ in order to select the correct one.

for the pos type it's not dificult by i'm trying to differenciate between the first position and subsequent ones without success.

all i could come up with was to check MAST for MATNR/WERKS/STLAN/STLAL in order to get the STLNR, check STAS for STLNR/STLAL to see if there are existing item positions.

here's the code:

  1. DATA : s_mast LIKE mast , s_stas LIKE stas.
  2. SELECT SINGLE * FROM mast INTO s_mast WHERE
  3. matnr = bomitem-matnr
  4. AND werks = bomitem-werks
  5. AND stlan = bomitem-stlan
  6. AND stlal = bomitem-stlal.
  7. IF sy-subrc = 0.
  8. SELECT SINGLE * FROM stas INTO s_stas WHERE
  9. stlnr = s_mast-stlnr
  10. AND stlal = bomitem-stlal.
  11. IF NOT sy-subrc = 0.
  12. IF bomitem-postp = 'L'.
  13. cs02l1 = init_cs02l1.
  14. ELSE.
  15. skip_record.
  16. ENDIF.
  17. ELSE.
  18. skip_record.
  19. ENDIF.
  20. ELSE.
  21. skip_record.
  22. ENDIF.

tried several times but at the convert data step no record is written unless i remove all the checks, giving me the feeling that i cannot perform SELECTs and probably not even declare variables in the _BEGIN_OF_RECORD_ space...

what am i doing wrong?

any solution?