Objektorientierung

Folgen Sie mir zu zwei Programmbeispielen in die objektorientierte Welt der ABAP/4 Entwicklungsumgebung. Nichts ist einfacher:


Senden Sie Ihren Kollegen einfach eine kurze Nachricht aus SAP:

 

  DATA: lo_doc   TYPE REF TO cl_document_bcs,
        lo_adr   TYPE REF TO cl_cam_address_bcs,
        lo_sen   TYPE REF TO cl_sapuser_bcs,
        lo_bcs   TYPE REF TO cl_bcs,
        lx_bcs   TYPE REF TO cx_bcs,
        l_result TYPE os_boolean.

  TRY.
*> create document
      lo_doc = cl_document_bcs=>create_from_text( i_text        = gt_text[]
                                                  i_subject     = gd_subject
                                                  i_sensitivity = 'O' ).

*> create recipient
      lo_adr = cl_cam_address_bcs=>create_internet_address( gd_bemail ).

*> create send_request
      lo_bcs = cl_bcs=>create_persistent( ).

*> add recipient
      lo_bcs->add_recipient( lo_adr ).

*> add document
      CALL METHOD lo_bcs->set_document( lo_doc ).

*> no status reports
      lo_bcs->set_status_attributes( i_requested_status = 'N'
                                     i_status_mail      = 'N' ).

*> set sender
      IF NOT gd_sender IS INITIAL AND gd_sender <> sy-uname.
        lo_sen = cl_sapuser_bcs=>create( gd_sender ).
        lo_bcs->set_sender( lo_sen ).
      ENDIF.

*> shoot
      l_result = lo_bcs->send( ).

    CATCH cx_bcs INTO lx_bcs.
      IF NOT lx_bcs->msgid IS INITIAL.
        MESSAGE ID     lx_bcs->msgid
                TYPE   lx_bcs->msgty
                NUMBER lx_bcs->msgno
                WITH   lx_bcs->msgv1
                       lx_bcs->msgv2
                       lx_bcs->msgv3
                       lx_bcs->msgv4.
      ENDIF.
  ENDTRY.

  CHECK l_result IS INITIAL.
  MESSAGE e250(ubc_csp) WITH gd_bemail.

Konvertieren Sie Ihre Barcodes in ERP Informationen:

 

 

  DATA: result        TYPE string,
        strlen        TYPE i.

  FIELD-SYMBOLS: <db> TYPE zsdms_gs1_db.



  CHECK NOT gd_scan IS INITIAL.

  DO gd_max_number_db TIMES.

    IF gd_scan = space.
      EXIT.
    ELSE.

      LOOP AT gt_db ASSIGNING <db>.

        CHECK NOT gd_scan = space.

        CLEAR: result, strlen.

        CHECK gd_scan(<db>-length_db) = <db>-db.

        IF NOT <db>-fieldname IS INITIAL.
*> info we need for further processing ...
          IF <db>-zzsep IS INITIAL.
*> fix length
            result = gd_scan+<db>-length_db(<db>-length_cont).
            CALL METHOD zsdms_gs1=>ref_gs1->set_property
              EXPORTING
                i_object  = <db>-fieldname
                i_content = result.
            strlen = <db>-length_db + <db>-length_cont.
            gd_scan(strlen) = space.
            SHIFT gd_scan LEFT DELETING LEADING space.
          ELSE.
*> variable length
            IF gd_scan CS <db>-zzsep.
              strlen = sy-fdpos - <db>-length_db.
              result = gd_scan+<db>-length_db(strlen).
              strlen = strlen + <db>-length_db + 1.
            ELSE.
              strlen = STRLEN( gd_scan ).
              strlen = strlen - <db>-length_db.
              result = gd_scan+<db>-length_db(strlen).
              strlen = <db>-length_db + <db>-length_cont.
            ENDIF.
            CALL METHOD zsdms_gs1=>ref_gs1->set_property
              EXPORTING
                i_object  = <db>-fieldname
                i_content = result.
            gd_scan(strlen) = space.
            SHIFT gd_scan LEFT DELETING LEADING space.
          ENDIF.

        ELSE.
*> info we do not need ...
          IF <db>-zzsep IS INITIAL.
            result = <db>-length_db + <db>-length_cont.
            gd_scan(result) = space.
            SHIFT gd_scan LEFT DELETING LEADING space.
          ELSE.
            strlen = sy-fdpos + <db>-length_db + 1.
            gd_scan(strlen) = space.
            SHIFT gd_scan LEFT DELETING LEADING space.
         
ENDIF.

        ENDIF.

      ENDLOOP.

    ENDIF.

  ENDDO.

Kontakt- und Terminvereinbarung

T +49 7835 4261770
M +49 1522 9215220

Rufen Sie mich über Skype an:

Skype Me™!

Folgen Sie mir:

Thomas Kesselring

Benutzen Sie das Kontakformular:

 

Kontakt