Difference between revisions of "SAP ISH ABAP"

From SapWiki
(Created page with "==Obtener extensión de documento (tabla NDOC)== <nowiki> data: ls_appl_data type RN2DT_APPLICATION, ls_pcdta type N2DTDTA. SELECT SINGLE dtid, dtvers int...")
 
 
(3 intermediate revisions by the same user not shown)
Line 36: Line 36:
 
       c_data-extension = 'DOC'.
 
       c_data-extension = 'DOC'.
 
     ENDIF.</nowiki>
 
     ENDIF.</nowiki>
 +
 +
==Obtener binario/visualizar documento==
 +
<nowiki>  data l_base64 type string.
 +
  data lt_document type TABLE OF RN2PCRAW255.
 +
  data l_length type N2_BYTES.
 +
 +
  data: lt_ndoc type STANDARD TABLE OF ndoc,
 +
        ls_draw type DRAW.
 +
 +
  if i_bin = abap_true. "obtener binario de documenro (xstring)
 +
  CALL FUNCTION 'ISH_N2_GET_CONTAINER_DOCUMENT'
 +
    EXPORTING
 +
      ss_dokar                  = c_data-dokar
 +
      ss_doknr                  = c_data-doknr
 +
      ss_dokvr                  = c_data-dokvr
 +
      ss_doktl                  = c_data-doktl
 +
    IMPORTING
 +
      SS_FILE_LENGTH            = l_length
 +
    TABLES
 +
      ss_dokument_content      = lt_document
 +
  EXCEPTIONS
 +
    DOCUMENT_NOT_FOUND        = 1
 +
    NO_RFC                    = 2
 +
    OTHERS                    = 3
 +
          .
 +
  IF sy-subrc <> 0 or lt_document[] is INITIAL.
 +
    return.
 +
  ENDIF.
 +
 +
  CALL METHOD cl_faa_tenv_services=>convert_xtable_to_xstring
 +
    EXPORTING
 +
      it_xtable    = lt_document
 +
    IMPORTING
 +
      ed_xstring    = c_data-binfile
 +
    EXCEPTIONS
 +
      invalid_table = 1
 +
      others        = 2
 +
        .
 +
  IF sy-subrc <> 0.
 +
* Implement suitable error handling here
 +
  ENDIF.
 +
else. "visualizar documento
 +
 +
  SELECT  * into TABLE lt_ndoc FROM  ndoc
 +
        WHERE  dokar  = c_data-dokar
 +
        AND    doknr  = c_data-doknr
 +
        AND    dokvr  = c_data-dokvr
 +
        AND    doktl  = c_data-doktl. "#EC CI_SEL_NESTED
 +
  if sy-subrc <> 0.
 +
    return.
 +
  endif.
 +
 +
  CALL FUNCTION 'ISH_N2_MEDICAL_DOCUMENT'
 +
    EXPORTING
 +
*    SS_BISDAT                =
 +
      ss_einri                = c_data-einri
 +
      SS_MODE                  = space
 +
*    SS_VONDAT                =
 +
      ss_tcode                = 'N203'
 +
*    SS_SELKR                = ' '
 +
*    SS_ENQUE                = ' '
 +
*    SS_SET_SCREEN_FLAG      = ' '
 +
*    SS_TITLE1                = ' '
 +
*    SS_TITLE2                = ' '
 +
*    SS_DOCLARCH              = ' '
 +
*    SS_DKTXT                =
 +
*    SS_RAISE_BATCH          =
 +
*  IMPORTING
 +
*    SS_OKCODE                =
 +
*    SS_TDWS                  =
 +
*    SS_TDWST                =
 +
*    SS_CMD_ERROR            =
 +
*    SS_SAVED                =
 +
  TABLES
 +
    SS_NDOC                  = lt_ndoc
 +
*    SS_COMMANDS              =
 +
  CHANGING
 +
    SS_DRAW                  = ls_draw
 +
  EXCEPTIONS
 +
    NO_DOCUMENT              = 1
 +
    NO_INSERT                = 2
 +
    CANCEL                  = 3
 +
    OTHERS                  = 4
 +
            .
 +
  IF sy-subrc <> 0.
 +
* Implement suitable error handling here
 +
  ENDIF.
 +
 +
 +
endif.</nowiki>
 +
 +
==Datos paciente==
 +
<nowiki>
 +
* Datos del Paciente
 +
  CALL FUNCTION 'ISH_READ_NPAT'
 +
    EXPORTING
 +
      ss_patnr              = iv_patnr
 +
      ss_read_db            = abap_true
 +
      ss_with_nadr          = abap_false
 +
      ss_no_buffering      = abap_true
 +
    IMPORTING
 +
      ss_npat              = ls_npat
 +
    EXCEPTIONS
 +
      not_found            = 1
 +
      no_authority          = 2
 +
      no_einri              = 3
 +
      no_treatment_contract = 4
 +
      OTHERS                = 5.
 +
</nowiki>
 +
 +
==Documentos paciente==
 +
<nowiki>
 +
    CALL FUNCTION 'ISH_N2_MEDDOC_GETLIST'
 +
      EXPORTING
 +
        im_maxrow              = lc_maxrow
 +
        im_with_all_parts      = abap_false
 +
      IMPORTING
 +
        ex_number_of_documents = lv_numdocs
 +
        et_documents_2        = c_documents
 +
      TABLES
 +
        filter_einri          = lr_einri
 +
        filter_patnr          = lr_patnr
 +
        filter_medok          = lr_medok
 +
        filter_dodat          = lr_dodat.
 +
</nowiki>

Latest revision as of 19:33, 19 July 2021

Obtener extensión de documento (tabla NDOC)

    data: ls_appl_data type RN2DT_APPLICATION,
          ls_pcdta type N2DTDTA.

      SELECT SINGLE dtid, dtvers into @data(ls_ndoc) FROM  ndoc
         WHERE  dokar  = @c_data-dokar
         AND    doknr  = @c_data-doknr
         AND    dokvr  = @c_data-dokvr
         AND    doktl  = @c_data-doktl. "#EC CI_SEL_NESTED

    CALL FUNCTION 'ISH_N2_READ_DOCUMENT_TYPE'
      EXPORTING
        ss_dtid                 = ls_ndoc-dtid
        ss_dtvers               = ls_ndoc-dtvers
        ss_einri                = c_data-einri
        SS_VCODE                = 'DIS'
      IMPORTING
*       SS_N2DT                 =
*       SS_N2DTT                =
        SS_PCDTA                = ls_pcdta
*       SS_ERROR_PCDTA          =
*       SS_DOCCATEGORY          =
*       SS_DOCCATEGORY_PC       =
*       SS_APPLICATION          =
        SS_APPL_NEW             = ls_appl_data
*       SS_FORMAT               =
     EXCEPTIONS
       NOT_FOUND_OBJECT        = 1
       WRONG_VCODE             = 2
       OTHERS                  = 3
              .
    IF sy-subrc = 0.
* Implement suitable error handling here
      c_data-extension = ls_pcdta-PCFEXT.
    else.
      c_data-extension = 'DOC'.
    ENDIF.

Obtener binario/visualizar documento

  data l_base64 type string.
  data lt_document type TABLE OF RN2PCRAW255.
  data l_length type N2_BYTES.

  data: lt_ndoc type STANDARD TABLE OF ndoc,
        ls_draw type DRAW.

  if i_bin = abap_true. "obtener binario de documenro (xstring)
  CALL FUNCTION 'ISH_N2_GET_CONTAINER_DOCUMENT'
    EXPORTING
      ss_dokar                  = c_data-dokar
      ss_doknr                  = c_data-doknr
      ss_dokvr                  = c_data-dokvr
      ss_doktl                  = c_data-doktl
    IMPORTING
      SS_FILE_LENGTH            = l_length
    TABLES
      ss_dokument_content       = lt_document
   EXCEPTIONS
     DOCUMENT_NOT_FOUND        = 1
     NO_RFC                    = 2
     OTHERS                    = 3
          .
  IF sy-subrc <> 0 or lt_document[] is INITIAL.
    return.
  ENDIF.

  CALL METHOD cl_faa_tenv_services=>convert_xtable_to_xstring
    EXPORTING
      it_xtable     = lt_document
    IMPORTING
      ed_xstring    = c_data-binfile
    EXCEPTIONS
      invalid_table = 1
      others        = 2
        .
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.
else. "visualizar documento

  SELECT  * into TABLE lt_ndoc FROM  ndoc
         WHERE  dokar  = c_data-dokar
         AND    doknr  = c_data-doknr
         AND    dokvr  = c_data-dokvr
         AND    doktl  = c_data-doktl. "#EC CI_SEL_NESTED
  if sy-subrc <> 0.
    return.
  endif.

  CALL FUNCTION 'ISH_N2_MEDICAL_DOCUMENT'
    EXPORTING
*     SS_BISDAT                =
      ss_einri                 = c_data-einri
      SS_MODE                  = space
*     SS_VONDAT                =
      ss_tcode                 = 'N203'
*     SS_SELKR                 = ' '
*     SS_ENQUE                 = ' '
*     SS_SET_SCREEN_FLAG       = ' '
*     SS_TITLE1                = ' '
*     SS_TITLE2                = ' '
*     SS_DOCLARCH              = ' '
*     SS_DKTXT                 =
*     SS_RAISE_BATCH           =
*   IMPORTING
*     SS_OKCODE                =
*     SS_TDWS                  =
*     SS_TDWST                 =
*     SS_CMD_ERROR             =
*     SS_SAVED                 =
   TABLES
     SS_NDOC                  = lt_ndoc
*     SS_COMMANDS              =
   CHANGING
     SS_DRAW                  = ls_draw
   EXCEPTIONS
     NO_DOCUMENT              = 1
     NO_INSERT                = 2
     CANCEL                   = 3
     OTHERS                   = 4
            .
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.


endif.

Datos paciente

* Datos del Paciente
  CALL FUNCTION 'ISH_READ_NPAT'
    EXPORTING
      ss_patnr              = iv_patnr
      ss_read_db            = abap_true
      ss_with_nadr          = abap_false
      ss_no_buffering       = abap_true
    IMPORTING
      ss_npat               = ls_npat
    EXCEPTIONS
      not_found             = 1
      no_authority          = 2
      no_einri              = 3
      no_treatment_contract = 4
      OTHERS                = 5.

Documentos paciente

    CALL FUNCTION 'ISH_N2_MEDDOC_GETLIST'
      EXPORTING
        im_maxrow              = lc_maxrow
        im_with_all_parts      = abap_false
      IMPORTING
        ex_number_of_documents = lv_numdocs
        et_documents_2         = c_documents
      TABLES
        filter_einri           = lr_einri
        filter_patnr           = lr_patnr
        filter_medok           = lr_medok
        filter_dodat           = lr_dodat.