Adressenaufbereitung mit CUSTOMER_ADDRESS_TO_ITF

DATA: lv_address TYPE bapiaddr3.
DATA: it_bapi_return TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY.
 
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
  EXPORTING
    username = sy-uname
  IMPORTING
    address  = lv_address
  TABLES
    return   = it_bapi_return.

DATA: lv_customer TYPE scustom.
lv_customer-name = lv_address-fullname.
lv_customer-street = lv_address-street.
lv_customer-postbox = lv_address-po_box.
lv_customer-postcode = lv_address-postl_cod1.
lv_customer-city   = lv_address-city.
lv_customer-country = lv_address-country.
lv_customer-region = lv_address-region.
lv_customer-telephone = lv_address-tel1_numbr.
lv_customer-email = lv_address-e_mail.

DATA: lv_sender_country TYPE szad_field-send_cntry.
lv_sender_country = 'US'.

DATA: it_address_lines TYPE tline_tab.

CALL FUNCTION 'CUSTOMER_ADDRESS_TO_ITF'
  EXPORTING
    is_customer        = lv_customer
    iv_sending_country = lv_sender_country
*   IV_NUMBER_OF_LINES = 5
  IMPORTING
    et_address         = it_address_lines.

cl_demo_output=>write_data( lv_address ).
cl_demo_output=>write_data( lv_customer ).
cl_demo_output=>write_data( lv_sender_country ).
cl_demo_output=>write_data( it_address_lines ).
cl_demo_output=>display( ).

Adressenaufbereitung mit ADDRESS_INTO_PRINTFORM

* https://www.berater-wiki.de/Adressenaufbereitung#Funktionsbaustein_ADDRESS_INTO_PRINTFORM

DATA: lv_address TYPE bapiaddr3.
DATA: it_bapi_return TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY.

CALL FUNCTION 'BAPI_USER_GET_DETAIL'
  EXPORTING
    username = sy-uname
  IMPORTING
    address  = lv_address
  TABLES
    return   = it_bapi_return.

DATA: ls_address TYPE  adrs1.
ls_address-title_text = lv_address-title_p.
ls_address-name1      = lv_address-fullname.
ls_address-street     = lv_address-street.
*  ls_address-po_box     = is_customer-postbox.
ls_address-post_code1 = lv_address-postl_cod1.
*  ls_address-region     = is_customer-region.
ls_address-city1      = lv_address-city.
ls_address-country    = lv_address-country.
DATA: lv_sender_country TYPE land1.
lv_sender_country = 'US'.

DATA: it_address_lines TYPE szadr_printform_table.
CALL FUNCTION 'ADDRESS_INTO_PRINTFORM'
  EXPORTING
    address_1               = ls_address
    address_type            = '1' "normal/company
    sender_country          = lv_sender_country
    *    number_of_lines         = 5
  IMPORTING
    address_printform_table = it_address_lines.
    
cl_demo_output=>write_data( ls_address ).
cl_demo_output=>write_data( lv_sender_country ).
cl_demo_output=>write_data( it_address_lines ).
cl_demo_output=>display( ).

[ABAP] Neue / obsolete Transaktionscodes für S/4 HANA suchen

* https://thinkdoforward.com/neue-transaktionen-mit-s-4hana-so-einfach-findest-zu-sie/
PARAMETERS: p_rel TYPE saprl DEFAULT '751'.
SELECT-OPTIONS: so_ta FOR lv_s_tcode.

START-OF-SELECTION.

  SELECT c~rel_name, c~s_tcode, c~t_tcode, tx~ttext
    INTO TABLE @DATA(it_prgn_corr2)
    FROM prgn_corr2 AS c
    INNER JOIN tstc AS t ON ( c~t_tcode = t~tcode )
    RIGHT OUTER JOIN tstct AS tx ON ( t~tcode = tx~tcode )
    WHERE c~rel_name >= @p_rel
      AND c~s_tcode IN @so_ta
      AND tx~sprsl = @sy-langu.

  SORT: it_prgn_corr2 BY s_tcode rel_name.


  TRY.
* SALV-Table
      DATA: o_salv TYPE REF TO cl_salv_table.

      cl_salv_table=>factory( IMPORTING
                                r_salv_table = o_salv
                              CHANGING
                                t_table      = it_prgn_corr2 ).

* Grundeinstellungen
      o_salv->get_functions( )->set_all( abap_true ).
      o_salv->get_columns( )->set_optimize( abap_true ).
      o_salv->get_display_settings( )->set_list_header( 'Überschrift' ).
      o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
      o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

      LOOP AT o_salv->get_columns( )->get( ) ASSIGNING FIELD-SYMBOL(<c>).
        DATA(o_col) = <c>-r_column.
        o_col->set_short_text( || ).
        o_col->set_medium_text( || ).
        o_col->set_long_text( |{ o_col->get_columnname( ) } [{ o_col->get_long_text( ) }]| ).
      ENDLOOP.

      o_salv->display( ).
    CATCH cx_root INTO DATA(e_txt).
      WRITE: / e_txt->get_text( ).
  ENDTRY.

[ABAP] Textpatterns in Strings mittles Vergleichsoperator CP (Covers Pattern) suchen

* https://www.berater-wiki.de/Vergleichsoperatoren_Zeichen
* Variante 1 (Wildcard)
DATA(lv_test) = |abc-123|.

IF lv_test CP '*-*'.
  WRITE: / '- in der Mitte.'.
ELSE.
  WRITE: / 'kein - in der Mitte'.
ENDIF.

* Variante 2 (bestimmtes Zeichen)
DATA(lv_test) = |abc-123|.

IF lv_test CP 'ABC-*'.
  WRITE: / 'Schema ABC-XXX'.
ELSE.
  WRITE: / 'kein Schema ABC-XXX'.
ENDIF.

* Variante 3 (bestimmtes Zeichen)
DATA(lv_test) = |abc-1234|.

IF lv_test CP '+++-+++'.
  WRITE: / 'Schema XXX-XXX'.
ELSE.
  WRITE: / 'kein Schema XXX-XXX'.
ENDIF.