2014年4月29日 星期二

How to read Report selection screen field values before PAI field transport

Function: DYNP_VALUES_READ

How to got the field value when you still in selection screen manipulating, example code as below:
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vbeln.
*--- Update P_VSTEL
  dyfields-fieldname 'P_VSTEL'.
  APPEND dyfields.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname     sy-cprog
      dynumb     sy-dynnr
    TABLES
      dynpfields dyfields.
  READ TABLE dyfields INDEX 1.

  IF dyfields-fieldvalue IS INITIAL.
    MESSAGE i899 WITH 'Please enter Shipping Point first!'.
    EXIT.
  ELSE.
    CLEARgr_vstel,  gr_vstel[],
           gt_lipov,  gt_lipov[],
           gt_dn,     gt_dn[].
    gr_vstel-sign   'I'.
    gr_vstel-option 'EQ'.
    gr_vstel-low    dyfields-fieldvalue.
    APPEND gr_vstel.
  ENDIF.

  CALL FUNCTION 'WS_LM_DATA_SELECTION'
    EXPORTING
      if_proctype     'W'
    TABLES
      it_vstel        gr_vstel
      ct_postab       gt_lipov
    EXCEPTIONS
      no_data_found   1
      wrong_proc_type 2
      OTHERS          3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  LOOP AT gt_lipov.
    CLEAR gt_dn.
    MOVE-CORRESPONDING gt_lipov TO gt_dn.
    SELECT SINGLE name1 INTO gt_dn-name1
      FROM kna1
      WHERE kunnr gt_dn-kunnr.
    APPEND gt_dn.
  ENDLOOP.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    'VBELN'
      dynpprog    sy-repid
      dynpnr      sy-dynnr
      dynprofield 'P_VBELN'
      value_org   'P'
    TABLES
      value_tab   gt_dn
      field_tab   gt_dfies2.

沒有留言:

張貼留言