Tuesday, December 21, 2010

REPORT ZTEST_prog1.

DATA:
      BEGIN OF IT_MARC OCCURS 0,
        MATNR TYPE MARC-MATNR,
        WERKS TYPE MARC-WERKS,
      END OF IT_MARC.
DATA:
      IT_DYNPREAD TYPE TABLE OF DYNPREAD,
      WA_DYNPREAD LIKE LINE OF IT_DYNPREAD.
DATA:
      IT_RETURN_TAB TYPE DDSHRETVAL OCCURS 0,
      WA_RETURN LIKE LINE OF IT_RETURN_TAB.
PARAMETERS:
      P_WERKS TYPE MARC-WERKS,
      P_MATNR TYPE MARC-MATNR.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MATNR.

  WA_DYNPREAD-FIELDNAME = 'P_WERKS'.
  APPEND WA_DYNPREAD TO IT_DYNPREAD.
  CLEAR  WA_DYNPREAD.
  "DYNP_VALUES_READ read screen
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      DYNAME     = SY-REPID
      DYNUMB     = SY-DYNNR
    TABLES
      DYNPFIELDS = IT_DYNPREAD.
  READ TABLE IT_DYNPREAD INTO WA_DYNPREAD INDEX 1.
  P_WERKS = WA_DYNPREAD-FIELDVALUE.
  IF IT_MARC[] IS INITIAL.
    SELECT * FROM MARC INTO CORRESPONDING FIELDS OF TABLE IT_MARC WHERE WERKS = P_WERKS.
  ENDIF.
  "F4 help F4IF_INT_TABLE_VALUE_REQUEST
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      RETFIELD    = 'MATNR'
      DYNPPROG    = SY-REPID
      DYNPNR      = SY-DYNNR
      DYNPROFIELD = 'P_MATNR'
      VALUE_ORG   = 'S'
    TABLES
      VALUE_TAB   = IT_MARC
      RETURN_TAB  = IT_RETURN_TAB.
  IF SY-SUBRC EQ 0.
    READ TABLE IT_RETURN_TAB INTO WA_RETURN INDEX 1.
    IF SY-SUBRC EQ 0.
      P_MATNR = WA_RETURN-FIELDVAL.
    ENDIF.
  ENDIF.

1 comment:

  1. when I was calling this func, sy-dynnr number is '3010' and went to shor dump with 'invalid_dynproname'. I have no idea how I handle it.

    ReplyDelete

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.