Skip to Content
0
Former Member
Sep 28, 2007 at 11:12 AM

Scripts

11 Views

Hi,

Please correct this code.

TABLES : likp, tvko,t005t, adrc.

DATA : co_addr LIKE adrc,
       adrnr LIKE tvko-adrnr,
       v_landx LIKE t005t-landx,
       cust_addr LIKE adrc.




PARAMETERS : p_vbeln LIKE likp-vbeln.

START-OF-SELECTION.

  PERFORM get_data.

END-OF-SELECTION.

  PERFORM show_form.
*&---------------------------------------------------------------------*
*&      Form  show_form
*&---------------------------------------------------------------------*

FORM show_form .
  CALL FUNCTION 'OPEN_FORM'
    EXPORTING
      device                      = 'PRINTER'
      dialog                      = 'X'
      form                        = 'ZSRINU_DEL'
      language                    = sy-langu
    EXCEPTIONS
      canceled                    = 1
      device                      = 2
      form                        = 3
      OPTIONS                     = 4
      unclosed                    = 5
      mail_options                = 6
      archive_error               = 7
      invalid_fax_number          = 8
      more_params_needed_in_batch = 9
      spool_error                 = 10
      codepage                    = 11
      OTHERS                      = 12.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    "show_form
*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
FORM get_data .
  SELECT SINGLE * FROM likp
                 WHERE vbeln = p_vbeln.

*---sales org address
  SELECT SINGLE adrnr FROM tvko
                 INTO tvko-adrnr
                 WHERE vkorg = likp-vkorg.

  IF NOT tvko-adrnr IS INITIAL.
    SELECT SINGLE * FROM adrc INTO co_addr.

  ENDIF.

  SELECT SINGLE landx FROM t005t
                      INTO v_landx
                      WHERE land1 = co_addr-country
                      AND spras = sy-langu.

  SELECT
         city1
        post_code1
        street
        country
  INTO CORRESPONDING FIELDS OF cust_addr
  FROM adrc AS a
  INNER JOIN kna1 AS b
  ON a~addrnumber = b~adrnr
  INNER JOIN likp AS c
  ON b~kunnr = c~kunnr
  WHERE vbeln = p_vbeln.
  ENDSELECT.


CALL FUNCTION 'WRITE_FORM'
 EXPORTING
   element                        = 'COMP_ADDR'
*     FUNCTION                       = 'SET'
*     TYPE                           = 'BODY'
   window                         = 'CO_ADDR'
 EXCEPTIONS
   element                        = 1
   function                       = 2
   type                           = 3
   unopened                       = 4
   unstarted                      = 5
   window                         = 6
   bad_pageformat_for_print       = 7
   spool_error                    = 8
   codepage                       = 9
   OTHERS                         = 10
          .
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.


ENDIF.


CALL FUNCTION 'WRITE_FORM'
  EXPORTING
    element                  = 'CUST_ADDR'
    window                   = 'CUST_ADD'
  EXCEPTIONS
    element                  = 1
    function                 = 2
    type                     = 3
    unopened                 = 4
    unstarted                = 5
    window                   = 6
    bad_pageformat_for_print = 7
    spool_error              = 8
    codepage                 = 9
    OTHERS                   = 10.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

                    " show_form



CALL FUNCTION 'CLOSE_FORM'
*IMPORTING
*  RESULT                   = RESULT
*  rdi_result               = rdi_result
*TABLES
*  otfdata                  = otfdata
EXCEPTIONS
  unopened                 = 1
  bad_pageformat_for_print = 2
  send_error               = 3
  spool_error              = 4
  codepage                 = 5
  OTHERS                   = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

ENDFORM.                    " GET_DATA

Regards

Srinu